I want to insert rows from a table in a server
into another table in another server using
INSERT SELECT command. For example :
INSERT INTO Server1.database1.dbo.Tab1
SELECT * FROM Server2.database2.dbo.Tab1
WHERE Col1 = 1
Can the command like this work ?
If not, could you give me the solution ?
Please help me
Thanks in advance
John Smile
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!You have the correct syntax. Assuming you have created a linked server on
the server where you run the code and provided you have the required
permissions then your INSERT statement looks OK. See the Linked Servers
topic in Books Online for details.
BUT, don't use SELECT * in production code and always list the target column
names in an INSERT statement. Following those good practices should make
your code easier to maintain if your table structures change.
--
David Portas
SQL Server MVP
--
No comments:
Post a Comment