SQL SERVER RULES

SQL SERVER RULES

Tuesday, February 7, 2012

Calling the Object(Stored Procedure) from a Linked server to Local SQL Server

hi Friends,

Today, I am going to share one of the most Interesting topic called LINKED SERVERS.

First of all what's it mean.

In the SQL SERVER one of the excellent feature called LINKED SERVER.The name itself indicating that the server can be add to a network group or single SQL SERVER, by stating the T-SQL commands we can the retrieve the data from the remote server databases, also we can combine the retrieved data with the local server data.

Basically we are having two ways to connect with the remote server.

Method 1: Turn your way to Object Explorer of sql server management studio
----->>> Click on the Server Objects to Expand there you can find the Excellent Option called LINKED SERVER,by Right clicking you can add NEW LINKED SERVER.

Method 2: By using the T-SQL commands of Stored Procedure we can connect to the Remote server.Open the Query Editor and Execute The commands.

sp_addlinkedserver,sp_addlinkedsrvlogin

That all Guys now I hope you guys get a basic idea about remote server(LINKED SERVER)

Now lets turn to our today s Goal 'CALLING THE OBJECT FROM A LINKED SERVER'

Two ways to crack the concept.

Case1: By using the four part Naming.

Syntax:

Exec [linked server].databasename.schemaname(database owner).storedprocedure 'params'

Case2:By Using Distributed Query Function(openquery())

Syntax:

select * from openquery([linked server].databasename.schemaname(database owner).storedprocedure 'params')


hope you guys got the basic idea about the LINKED SERVERS, like me.





No comments: