Home > Net >  how to copy value from databse1.table1.culomn1 to database2.table1.culomn1 in Sql Server
how to copy value from databse1.table1.culomn1 to database2.table1.culomn1 in Sql Server

Time:09-16

I have 2 similar databases with the same structure and different values in SQL Server I want to copy the values of one column of the table from the first database to the second database in the same table and column

database1.table1.culomn1=databse2.table1.culomn1

Thank you

CodePudding user response:

here's an exemple query to perform an update:

UPDATE t2
SET t2.culomn1 = t1.culomn1
FROM database1.table1 t1
INNER JOIN databse2.table1 t2 ON t1.Id = t2.Id

CodePudding user response:

INSERT INTO db2.schema2.table2 (col2) SELECT col1 FROM db1.schema1.table1 GO col1:the column you wanna copy col2:the column you wanna put the data copied into but before that, you will need to create the col2 and they should be the same data type.

  • Related