Trying to create a Update query to update data from one table to another

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jrsonner
    New Member
    • Mar 2008
    • 2

    Trying to create a Update query to update data from one table to another

    I have multiple entries in one table that I need to update the entries in the current production table with, to revert that data back before a migration so I can migrate that data again.

    The queries I wrote to find the entries that need to be updated is below. There are four queries that I ran to find the information. There is a total of about 2500 lines that need to be updated.

    Select * from St_Page
    where fname like '01-%'

    Select * from St_Page
    where fname like 'h8%'

    Select * from St_Page
    where fname like 'h9%'

    Select * from St_Page
    where fname like 'ha%'


    I checked the two tables and there are a total of 9 fields. 4 need to be updated the other 5 stay the same. The fields that need to be updated are VOLNAME, ADDDATE, SECTOR, and EXTID.

    I am guessing I want to use the FNAME field to find the objects to update. Any ideas on how to write this update query. Both St_Page tables will be in the same instance of SQL but in different databases.
  • amitpatel66
    Recognized Expert Top Contributor
    • Mar 2007
    • 2358

    #2
    Originally posted by jrsonner
    I have multiple entries in one table that I need to update the entries in the current production table with, to revert that data back before a migration so I can migrate that data again.

    The queries I wrote to find the entries that need to be updated is below. There are four queries that I ran to find the information. There is a total of about 2500 lines that need to be updated.

    Select * from St_Page
    where fname like '01-%'

    Select * from St_Page
    where fname like 'h8%'

    Select * from St_Page
    where fname like 'h9%'

    Select * from St_Page
    where fname like 'ha%'


    I checked the two tables and there are a total of 9 fields. 4 need to be updated the other 5 stay the same. The fields that need to be updated are VOLNAME, ADDDATE, SECTOR, and EXTID.

    I am guessing I want to use the FNAME field to find the objects to update. Any ideas on how to write this update query. Both St_Page tables will be in the same instance of SQL but in different databases.
    Are you looking at updating a table of one database with a table of another database? In taht case you will need to use databse link to connect both the databases and do an update.

    Comment

    • jrsonner
      New Member
      • Mar 2008
      • 2

      #3
      Yes I am going to import the data for the ST_page table before the migration into the SQL instance as a different database. I do not want to interfer with the production database. I do need to update the ST_page table in the production database with the ST_page table information from before the migration which I thought the best way was to import that table into a different database. Both tables with then be in the same instance of SQL just not in the same database. I don't know how to create the update or the connection you are talking about. Any help would be greatly appreciated.

      Comment

      Working...