I am trying to update database fields from one SQL Server table to another.
Our production SQL Server is [spdbprod.test.com\spprod], our QA server is [spdbQA.test.com\spQA].
I need to update table in production from QA table. I using this SQL statement but, it is giving an error.
UPDATE
[spdbprod.test.com\spprod].[aspnetdb].[dbo].[Communities_Groups] as t1
SET
t1.Show = (Select t2.show from [spdbQA.test.com\spQA].[aspnetdb].[dbo].
[Communities_Groups] as t2 where t1.GroupID = t2.GroupdID)
What I am missing here?
Error:
UPDATE. (“Incorrect syntax near the keyword ‘as’.”)
You are using table alias in a wrong way. You cannot do
UPDATE table1 t SET field1=val, you have to writeUPDATE table1 SET field=val(OrUPDATE table1 SET field=val FROM table1 t). So change your query to