Search code examples
c#asp.netsqllinked-server

Connect Linked Server Programmatically C#


Possible Duplicate:
SQL - Connect to Linked Server with Named Instance

I want to connect to a Remote Server DB using Linked Servers. I want this connection to be done by a C# program. How to connect these Linked Servers in C#?


Solution

  • A linked server is an object on a SQL Server instance, so if you connect to that instance you can query the linked server as if you were quering any other object on one of the instance's databases.

    here is an example:

    SELECT * 
    FROM OPENQUERY ( <linked_server>, 'select code, name, from your_table')
    

    Not sure if this is the answer you were looking for, maybe if you provide more details of your scenario e can help you a little bit more