3

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#?

2
  • 3
    what do you mean by connecting? The idea of linked server is to connect on server A, and execute queries on server B while connected to A... Commented Jul 19, 2012 at 9:31
  • @Ethan - stackoverflow.com/questions/29795658/… Commented Apr 22, 2015 at 12:17

2 Answers 2

4

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

Sign up to request clarification or add additional context in comments.

Comments

3

You can do it in sql just like an other Sql Query apart from giving linkedserver name in it, so the connection string remain the usual way we use without a linked server Here is nice site that gives various types of connectionstrings

SELECT * FROM linkedServerName.TheDatabaseName.dbo.TheTableName

2 Comments

I am not asking aboutn data fetching. The initial connection to that sever through C# is what I asked.
@Ethan sorry mate i will update my answer in a minute

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.