My First Multiple Record Update Transaction???

  • 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

  • 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


    If you can't explain to another person how the code that you're copying from the internet works, then DON'T USE IT on a production system! After all, you will be the one supporting it!
    Links:
    For better assistance in answering your questions
    Performance Problems
    Common date/time routines
    Understanding and Using APPLY Part 1 & Part 2

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply