none
Linked Server Connection String ??

    Question

  •  

    What is the connection string for access a database of a linked server in sqlserver

     

    Thanks

     

    I add a linked server (another sqlserver server2) to my sqlserver(server1) , I need make a sqlconnection to the linked server connecting my sqlserver (server1)

    Tuesday, April 22, 2008 10:59 PM

Answers

All replies

  • Can you follow this BOL page to create linked server?

    http://msdn2.microsoft.com/en-us/library/ms190479.aspx

     

    If you still see problem, please let use us know the command you used and the error message you get?

    Thanks,

     

    Wednesday, April 23, 2008 9:24 PM
  •  Xinwei Hong - MSFT wrote:

    Can you follow this BOL page to create linked server?

    http://msdn2.microsoft.com/en-us/library/ms190479.aspx

     

    If you still see problem, please let use us know the command you used and the error message you get?

    Thanks,

     

     

    I create a linked server , now i try to acces to the linked server with

     

    Dim vpoConexion As SqlClient.SqlConnection
    vpoConexion = New SqlClient.SqlConnection(ConnString)
    vpoConexion.open

     

    ConnString ???? what is the connection string

    Wednesday, April 23, 2008 11:02 PM
  • Once you created a linked server, you don't need a connection string.

    Just make a connection to your primary server and do some query, e,g.

    --List the tables in the linked server.
    EXEC sp_tables_ex txtsrv
    GO

    --Query one of the tables: file1#txt
    --using a four-part name.
    SELECT *
    FROM txtsrv...[file1#txt]

     

    where txtsrv is a your linked server name.

    Wednesday, April 23, 2008 11:09 PM
  •  Xinwei Hong - MSFT wrote:

    Once you created a linked server, you don't need a connection string.

    Just make a connection to your primary server and do some query, e,g.

    --List the tables in the linked server.
    EXEC sp_tables_ex txtsrv
    GO

    --Query one of the tables: file1#txt
    --using a four-part name.
    SELECT *
    FROM txtsrv...[file1#txt]

     

    where txtsrv is a your linked server name.

     

    Ok

    but for that connectionString="Server=192.168.1.210; Database=???; User Id=user; password=pwd

    what i put in database ?

     

    There are a way to dont use txtsrv.nameoftable ?

     

    Wednesday, April 23, 2008 11:23 PM
  • The Database should be the database we want to use when you are connected to the server, e.g. master, etc. You can read this blog to learn more about linked server

    http://blogs.msdn.com/sql_protocols/archive/2006/08/10/694657.aspx

     

    • Proposed as answer by Kalman Toth Saturday, March 19, 2011 11:48 AM
    Wednesday, April 23, 2008 11:48 PM
  • I just figured this out for myself in SQL Server 2008 R2. The trick is that you can specify ANY database within the server instance. For example:

    connectionString="Server=192.168.1.210; Database=master; User Id=user; password=pwd

    Then, you query the linked server like this from your app:

    SELECT * FROM MyLinkedServerName...TableName

    So according to your original post, Server1 would go in your connection string and Server2 would go in your select statement.

    HTH.

    • Proposed as answer by William Fields Friday, February 25, 2011 6:34 PM
    Friday, February 25, 2011 6:24 PM