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
 General SQL Server Forums
 New to SQL Server Programming
 Replace

Author  Topic 

velvettiger
Posting Yak Master

115 Posts

Posted - 2008-07-10 : 14:43:27
Hi Guys,

I ran a query but only the old card numbers are coming up. I managed to locate a file which contains a list with the new cards and old cards.

How would you replace the old cards with the new cards.

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-07-10 : 14:54:23
EIther dump file data on to a staging table and do an update like

UPDATE t
SET t.CardNumber=s.NewNumber
FROM Table t
INNER JOIN Staging s
ON t.CardNumber=s.OldNumber



or use OPENROWSET to directly take it from file.
Go to Top of Page

velvettiger
Posting Yak Master

115 Posts

Posted - 2008-07-10 : 15:01:23
When you say staging table you mean a temporary table?
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-07-11 : 01:15:16
quote:
Originally posted by velvettiger

When you say staging table you mean a temporary table?


nope just create a new table and transfer data to it using DTS/SSIS.If you dont wish to create a table use OPENROWSET which takes fields directly from file.
Go to Top of Page
   

- Advertisement -