You must Sign In to post a response.
  • Category: SQL Server

    In Sql Connect Server1 db table to server2 db Table

    How can i refer Server1 db Tables refer to Server2 db .. If its possible ? pls. share some ideas..
  • #761983
    Hi

    You can put 2 separate connection string in your webconfig file then get string in your c# code and process your function. I have mention below webconfig and c# Code.


    Webconfig code


    <add name="SERVER1Connectionstring" connectionString="data Source=your string"/>
    <add name="SERVER2Connectionstring" connectionString="data Source=your string"/>


    From Retrieve C# Code




    private string GetConnectionStringServer1()
    {
    return System.Configuration.ConfigurationManager.ConnectionStrings["SERVER1Connectionstring"].ToString();
    }


    private string GetConnectionStringServer2()
    {
    return System.Configuration.ConfigurationManager.ConnectionStrings["SERVER2Connectionstring"].ToString();
    }


    Name : Dotnet Developer-2015
    Email Id :kumaraspcode2009@gmail.com

    'Not by might nor by power, but by my Spirit,' says the LORD Almighty.

  • #761984
    Hi.. Thanks for your response but i am asking this process in sql server level only .... EX : linked server.. any idea about this. how to call this two diff. sql server

  • #761985
    Hi

    You can go through Below link

    https://msdn.microsoft.com/en-us/library/ms190479.aspx

    http://www.sqlmatters.com/Articles/Changing%20the%20SQL%20Server%20connection%20within%20an%20SSMS%20Query%20Windows%20using%20SQLCMD%20Mode.aspx

    https://www.mssqltips.com/sqlservertip/1767/execute-sql-server-query-on-multiple-servers-at-the-same-time/


    SELECT *
    FROM server1table
    INNER JOIN server2.database.dbo.server2table ON

    Name : Dotnet Developer-2015
    Email Id :kumaraspcode2009@gmail.com

    'Not by might nor by power, but by my Spirit,' says the LORD Almighty.

  • #761986
    If the server in in the sys.servers
    "select * from sys.servers"

    you can call the query as follows in the SQL

    SELECT * FROM [WIN-RD89S5PJ8MP].[MyDBName].[dbo].[Emp]

    By Nathan
    Direction is important than speed


Sign In to post your comments