Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase 12»»

Merge Statement over a linked server Expand / Collapse
Author
Message
Posted Saturday, November 24, 2012 3:42 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Wednesday, May 28, 2014 5:33 PM
Points: 5, Visits: 100
Does anyone know a way of running a MERGE statement across 2 tables over a linked server?

Getting the message "The target of a MERGE statement cannot be a remote table, a remote view, or a view over remote tables."
Post #1388342
Posted Saturday, November 24, 2012 6:08 PM


Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Monday, September 29, 2014 5:52 AM
Points: 369, Visits: 1,215
Try executing the whole statement at destination db:

EXEC('MERGE ...') AT MYDBLINKNAME

What is remote server? Sql server, oracle or something else?


_____________________________________________________
Microsoft Certified Master: SQL Server 2008
XDetails Addin - for SQL Developers
blog.sqlxdetails.com - Transaction log myths
Post #1388351
Posted Sunday, November 25, 2012 6:00 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Wednesday, May 28, 2014 5:33 PM
Points: 5, Visits: 100
Thanks for the suggestion, i'll give it a try.

This is SQL 2008R2 setup I'm trying to run it on.
Post #1388392
Posted Monday, November 26, 2012 1:45 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Wednesday, May 28, 2014 5:33 PM
Points: 5, Visits: 100
Tried it yesterday and it worked perfectly. Thanks again.
Post #1388827
Posted Monday, November 26, 2012 3:57 PM


Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Monday, September 29, 2014 5:52 AM
Points: 369, Visits: 1,215
You're welcome!

_____________________________________________________
Microsoft Certified Master: SQL Server 2008
XDetails Addin - for SQL Developers
blog.sqlxdetails.com - Transaction log myths
Post #1388884
Posted Tuesday, April 23, 2013 8:51 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Thursday, November 20, 2014 2:13 AM
Points: 37, Visits: 123
how does the query works?
Post #1445491
Posted Tuesday, April 23, 2013 8:57 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 10:12 AM
Points: 5,259, Visits: 12,195
girl_bj0619 (4/23/2013)
how does the query works?


Execute At [linked_server]

causes the statement to be executed on the linked server (not on the server running the EXECUTE statement). Is that what you mean?

--Edit: fix typo



Help us to help you. For better, quicker and more-focused answers to your questions, consider following the advice in this link.

When you ask a question (and please do ask a question: "My T-SQL does not work" just doesn't cut it), please provide enough information for us to understand its context.
Post #1445493
Posted Tuesday, April 23, 2013 10:40 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Thursday, November 20, 2014 2:13 AM
Points: 37, Visits: 123
i meant where to apply it?

here..?
merge ...
using....
Post #1445570
Posted Tuesday, April 23, 2013 10:48 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 10:12 AM
Points: 5,259, Visits: 12,195
girl_bj0619 (4/23/2013)
i meant where to apply it?

here..?
merge ...
using....


Can you take a bit more time to write out what you are trying to do please, because I do not understand your question?



Help us to help you. For better, quicker and more-focused answers to your questions, consider following the advice in this link.

When you ask a question (and please do ask a question: "My T-SQL does not work" just doesn't cut it), please provide enough information for us to understand its context.
Post #1445575
Posted Tuesday, April 23, 2013 11:16 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: 2 days ago @ 9:10 AM
Points: 13,230, Visits: 12,709
I think you are asking where do you run the MERGE???

EXEC('Your Entire MERGE Statement goes here') at LinkServer



_______________________________________________________________

Need help? Help us help you.

Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

Need to split a string? Try Jeff Moden's splitter.

Cross Tabs and Pivots, Part 1 – Converting Rows to Columns
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs
Understanding and Using APPLY (Part 1)
Understanding and Using APPLY (Part 2)
Post #1445592
« Prev Topic | Next Topic »

Add to briefcase 12»»

Permissions Expand / Collapse