Reputation: 9856
I want to move data from Column Col11 of DB1.Table1 into Col555 of DB2.Table7, based on a certain condition. How do I do it ? Is there a statement like -
select Col11 from DB1.Table1
into Col555 of Db2.Table7
where Col11 = 'Important'
Upvotes: 2
Views: 8091
Reputation: 6999
You don't need COPY
or INSERT
but UPDATE
(using JOIN):
UPDATE [DB2].[Table7]
SET [Table7].[Col555] = [Table1].[Col11]
FROM [Table1] JOIN [Table7] ON -- add the base for the join here...
WHERE [Table1].[Coll] = 'Important'
See this post for more details: SQL update query using joins
Upvotes: 2
Reputation: 647
INSERT INTO [DB2].[Table7] (Col555)
SELECT [Table1].[Col11]
FROM [DB1].[Table1]
WHERE [Table1].[Coll] = 'Important'
--May need .[dbo] or schema name between database and table names.
Upvotes: 0
Reputation: 1130
INSERT INTO DB2.TABLE2(col555)
SELECT Col11 FrOM DB1.TABLE1
WHERE Col11 = 'important'
Upvotes: 0