2

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'
Steam
  • 9,368
  • 27
  • 83
  • 122
  • This would be like ETL inside SQL server. But, I'd rather not use an ETL tool for this. – Steam Oct 18 '13 at 22:24

3 Answers3

2

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

Community
  • 1
  • 1
Yosi Dahari
  • 6,794
  • 5
  • 24
  • 44
0
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.

DeanG
  • 617
  • 4
  • 6
0
  INSERT INTO DB2.TABLE2(col555)
  SELECT Col11 FrOM DB1.TABLE1
  WHERE  Col11 = 'important'
jcwrequests
  • 1,132
  • 1
  • 7
  • 13