Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
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: Tuesday, May 5, 2015 8:03 PM
Points: 5, Visits: 109
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, July 11, 2016 7:38 AM
Points: 370, Visits: 1,248
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: Tuesday, May 5, 2015 8:03 PM
Points: 5, Visits: 109
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: Tuesday, May 5, 2015 8:03 PM
Points: 5, Visits: 109
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, July 11, 2016 7:38 AM
Points: 370, Visits: 1,248
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
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Thursday, April 28, 2016 8:16 PM
Points: 58, Visits: 173
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:42 AM
Points: 7,296, Visits: 17,695
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.

Never attribute to malice that which is adequately explained by stupidity
Post #1445493
Posted Tuesday, April 23, 2013 10:40 AM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Thursday, April 28, 2016 8:16 PM
Points: 58, Visits: 173
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:42 AM
Points: 7,296, Visits: 17,695
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.

Never attribute to malice that which is adequately explained by stupidity
Post #1445575
Posted Tuesday, April 23, 2013 11:16 AM


SSCoach

SSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoach

Group: General Forum Members
Last Login: Today @ 12:37 PM
Points: 15,819, Visits: 16,190
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