?
Solved

Linked server stored procedure

Posted on 2013-06-11
5
Medium Priority
?
537 Views
Last Modified: 2013-06-20
Hi

I have to call stored procedure on remote server using Linked server(SQL). stored procedure expects 10 parameters to be passed.  It also raise exception if something goes wrong. Would it be good practice to call linked server stored procedure directly from C# code or i should have stored procedure on local server sql that in turn calls linked server stored procedure. Can somebody suggest how to do it? i.e syntax and snippet

Thanks
0
Comment
Question by:KashyapVachhani
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 1500 total points
ID: 39240320
>I have to call stored procedure on remote server using Linked server(SQL)

>call linked server stored procedure directly from C#

Linked server is a SQL Server concept so if you call it directly from C# then its not linked server. Do you have access to this server directly from C#? I think you can do it either way.
0
 
LVL 2

Expert Comment

by:vivekkumarSharma
ID: 39240474
You can call it in either way.

But
I think you should have stored procedure on local SQL server that in turn calls linked server stored procedure.
If you call multiple servers from your program, It will leads to confusion and will create extra efforts to maintain multiple connection string.
0
 
LVL 14

Expert Comment

by:Christopher Gordon
ID: 39240818
If I understand your question,

If you have appropriate permissions, I would create an additional connectionstring in the web.config file to call the stored procedure to the additional SQL Server box directly.  Just wrap that call in a standard Try Catch block in your C# code.
0
 
LVL 18

Expert Comment

by:lludden
ID: 39241202
If possible, call the server directly.  A linked server just adds unnecessary complexity.
0
 
LVL 4

Expert Comment

by:BAKADY
ID: 39242805
This works for me,... let me now if you have problem running this:
EXEC yourDatabaseAtLinkedServer.dbo.yourStoredProcedure 'parametersIfRequired', 1, 2, 3, ...
AT YourLinkedServer
GO

Open in new window

http://msdn.microsoft.com/de-de/library/ms188332.aspx
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Naughty Me. While I was changing the database name from DB1 to DB_PROD1 (yep it's not real database name ^v^), I changed the database name and notified my application fellows that I did it. They turn on the application, and everything is working. A …
Hi all, It is important and often overlooked to understand “Database properties”. Often we see questions about "log files" or "where is the database" and one of the easiest ways to get general information about your database is to use “Database p…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question