question

Neda avatar image
Neda asked

How to update data in one table from corresponding data in another table and another SQL Server 2008?

I couldn't work with linked server as administrator didn't let me to do that. Therefore, I've imported the required tables in another database. Since source data is on another server, how can I update them? I appreciate quick reply as it is almost emergency. Thanks
sql-server-2008sql-serverlinked-server
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

aslam2510 avatar image
aslam2510 answered
Hoe this will help you. DECLARE @LastDatatime DATETIME SELECT @LastDatatime = MAX(audit_trail_date) FROM LogDB.LogTb INSERT INTO LogDB.LogTb SELECT column1, column 2... FROM (SELECT column1, column2.. FROM [LinkEDServer].[LogDB].[dbo].[LogTb] WHERE audit_trail_date > @LastDatatime)
2 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Neda avatar image Neda commented ·
Thanks for your answer, but I don't have any linked server already. The query need to write [LinkEDServer].
0 Likes 0 ·
aslam2510 avatar image aslam2510 commented ·
If possible create linked server another wise you have to look for replication.
0 Likes 0 ·
JohnM avatar image
JohnM answered
You should be able do this via SSIS as well. OPENROWSET also might be an option depending on what you need to update. For reference: https://msdn.microsoft.com/en-us/library/ms190312.aspx Hope that helps!
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.