|
Question : Select table data from a different SQL instance?
|
|
I have a production SQL instance "Host1\SQL1" and a testing SQL instance "Host1\SQL2". I've trying to copy data from the Production SQL instance to the testing SQL instance, like this: (but it isn't working) What as I missing? (running SQL from "Host1\SQL2") UPDATE PageTemplates SET TemplateText = (SELECT PT1.TemplateText FROM [Host1\SQL1].MyDB.PageTemplates AS PT1 WHERE (PT1.TemplateID = 1)) WHERE (TemplateID = 1)
|
|
Answer : Select table data from a different SQL instance?
|
|
FIrst, I assume if you run this fragment in a new query window, you get the result you are looking for:
SELECT PT1.TemplateText FROM [Host1\SQL1].MyDB.PageTemplates AS PT1 WHERE (PT1.TemplateID = 1)
If not, what result do you get?
(BTW, I just noticed - shouldn't that be FROM [Host1\SQL1].MyDB.dbo.PageTemplates AS PT1 -- add the dbo?)
Second: Do you get an error when you run your update?
Third: Try making both instance/DBs explicit, e.g.:
UPDATE [Host1\SQL2].MyDB.dbo.PageTemplates SET TemplateText = (SELECT PT1.TemplateText FROM [Host1\SQL1].MyDB.dbo.PageTemplates AS PT1 WHERE (PT1.TemplateID = 1)) WHERE (TemplateID = 1)
|
|
|
|