February 17, 2010 at 2:45 pm
Hi, I have figured out how to write a very basic update script for 1 record at a time where I SET the new value. I would like to know how to update lots of records at one time based on values in a new table, that should replace values in an old table. ( New values are imported from a basic spreadsheet and dumped into a new table within the database that has no links or relationships to anything)
Database = Vista
Table to recieve update = Device_T.Serial_Number
Table that has new data=Validated_SN.Validated_SN
Common field to both old and new tables is called Unique_ID
I really have no idea where to start, could somebody point me in the right direction? Thanks in Advance
February 17, 2010 at 3:07 pm
g_dion (2/17/2010)
Hi, I have figured out how to write a very basic update script for 1 record at a time where I SET the new value. I would like to know how to update lots of records at one time based on values in a new table, that should replace values in an old table. ( New values are imported from a basic spreadsheet and dumped into a new table within the database that has no links or relationships to anything)Database = Vista
Table to recieve update = Device_T.Serial_Number
Table that has new data=Validated_SN.Validated_SN
Common field to both old and new tables is called Unique_ID
I really have no idea where to start, could somebody point me in the right direction? Thanks in Advance
UPDATE u
SET Serial_number = n.Validated_SN
FROM dbo.Device_T u
INNER JOIN dbo.Validated_SN n
ON n.Unique_ID = u.Unique_ID
Oh... once you have this in your query window, double-click the word "update", and then press F1.
Wayne
Microsoft Certified Master: SQL Server 2008
Author - SQL Server T-SQL Recipes
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply