Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 SSIS and Import/Export (2005)
 Simple data transfer

Author  Topic 

duleepnagahawatte
Starting Member

16 Posts

Posted - 2007-12-27 : 07:59:39
Greetings all,
I have two databases and need to transfer some data from one to the other based on the "employee_Number".
"Table 1 and 2" both have a complete listing of employees but in "Table 1" certain columns are empty. I need to see if "Table 2" has got data in those columns and if yes import them to the "Table 1" based on the "Employee Number"
What is the simplest way to do this. both are on SQl server.
please Help

Thanks in advance........

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2007-12-27 : 08:09:21
If both databases are on the same server, you can write a simple update statement.

UPDATE T1
SET COL1 = T2.COL1,
COL2 = T2.COL2,
...
FROM TABLE1 T1 JOIN TABLE2 T2
ON T1.ENO = T2.ENO
WHERE T2.COL1 IS NOT NULL AND T2.COL2 IS NOT NULL...


Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-01-01 : 09:39:01
And if they are on different servers then first transfer data from Table 2 onto a staging table in Table A's server using data flow task in SSIS. Then using execute SQL task do the update after checking the field values of matching empno records.
If its for a single time you can even use Export/Import wizard to stage data to temporary table and then apply update script as below.
Go to Top of Page

duleepnagahawatte
Starting Member

16 Posts

Posted - 2008-01-08 : 06:11:30
Thanks Guys
Go to Top of Page
   

- Advertisement -