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)
 Import data in existing table

Author  Topic 

redfive
Starting Member

4 Posts

Posted - 2009-01-16 : 14:43:25
Really need you help on this,
I have been given a xls file with updated records ,
and need to import in to sql 2005 ,
The problem i have is how do i replace existing data ,
Say i have a table with index col1 , col2 , (Same is sql)
How do I just replace the existing data in col2, I have 3000 records and don’t want to input the data manually, the index in sql and xls match, Please can someone help,

sodeep
Master Smack Fu Yak Hacker

7174 Posts

Posted - 2009-01-16 : 16:50:44
1) Load to staging table and You can use Lookup Transformation Task in SSIS and based on lookup table you can update or insert.

Go to Top of Page

redfive
Starting Member

4 Posts

Posted - 2009-01-16 : 16:54:10
Thankyou Kind Sir

I,ll give it a go

Go to Top of Page

sodeep
Master Smack Fu Yak Hacker

7174 Posts

Posted - 2009-01-16 : 17:20:06
You are Welcome.
Go to Top of Page

sodeep
Master Smack Fu Yak Hacker

7174 Posts

Posted - 2009-01-16 : 19:14:04
Really Cool feature if SQL 2008:

This is code from Booksonline(2008):

MERGE Production.UnitMeasure AS target
USING (SELECT @UnitMeasureCode, @Name) AS source (UnitMeasureCode, Name)
ON (target.UnitMeasureCode = source.UnitMeasureCode)
WHEN MATCHED THEN
UPDATE SET Name = source.Name
WHEN NOT MATCHED THEN
INSERT (UnitMeasureCode, Name)
VALUES (source.UnitMeasureCode, source.Name)
OUTPUT deleted.*, $action, inserted.*;

Go to Top of Page

redfive
Starting Member

4 Posts

Posted - 2009-01-25 : 12:53:25
Sorry for the late responce ,
It worked , Sodeep thanks for your help
Go to Top of Page
   

- Advertisement -