Sql updating a table from another table
As the title suggests, I am trying to update one column from a column in another table.
if you have common field in both table then it's so easy !
This is what I wrote also, these different tables are in seperate SQL servers dbo_finance table is in dev01.finance(server, database) and assets C table is in dev02.dw(server, database) didnt know to do that so i left it out for [email protected] toby, primary key in Assets C is a security ID field that doesnt match anything in dbo_finance, completely unrelated field, what will match up is my dbo_finance key is cusip9, that should match up perfectly with assets C.cusip (assets C.cusip will always be unique)MERGE INTO dbo_finance USING (SELECT Issue Name1, cusip FROM Assets C WHERE Min Sec Class = 9) AS source ON dbo_= source.where (column1,column2) in ( I didn't down rate, but it isn't a good solution.Firstly: if the subselect was returning multiple values, then the for loop will be overwriting the name on table2 multiple times for some/all records (not clean). Assuming the outcome of the for loop was intended, the original subselect could have been rewritten in some controlled way to return only 1 value for each record...I need to update the table in Test1 from the same table in Test2 for a particular column called Dept ID, because the values in the Employee table in the Test2 DB (the old one) have been updated.So I need to update the table in the new DB from the table in the old DB which has around 1000 rows.
Search for sql updating a table from another table:
After each exercise, we provide the solution so you can check your answer.