Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
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.
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.
redfive
Starting Member
4 Posts
Posted - 2009-01-16 : 16:54:10
Thankyou Kind SirI,ll give it a go
sodeep
Master Smack Fu Yak Hacker
7174 Posts
Posted - 2009-01-16 : 17:20:06
You are Welcome.
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.*;
redfive
Starting Member
4 Posts
Posted - 2009-01-25 : 12:53:25
Sorry for the late responce , It worked , Sodeep thanks for your help