T-SQL Distributed queries

Source: Internet
Author: User

--returns a list of linked servers defined in the local server. EXECsys.sp_linkedservers/*creates or updates a mapping between logins on a local instance of SQL Server and security accounts in the remote server.  When a user logs on to a local server and executes a distributed query to access a table on a linked server, the local server must log on to the linked server and access the table on behalf of that user. Use sp_addlinkedsrvlogin to specify the logon credentials that the local server uses to log on to the linked server*/EXECSys.sp_addlinkedsrvlogin@rmtsrvname = NULL,--sysname    @useself = "',--varchar (8)    @locallogin = NULL,--sysname    @rmtuser = NULL,--sysname    @rmtpassword = NULL --sysname    /*create a linked server. A linked server allows users to distribute heterogeneous queries against OLE DB data sources. After you create a linked server by using sp_addlinkedserver, you can run distributed queries against that server. If the linked server is defined as an instance of SQL Server, you can execute a remote stored procedure. */  EXECSys.sp_addlinkedserver@server = NULL,--sysname    @srvproduct =N"',--nvarchar (+)    @provider =N"',--nvarchar (+)    @datasrc =N"',--nvarchar (4000)    @location =N"',--nvarchar (4000)    @provstr =N"',--nvarchar (4000)    @catalog = NULL --sysname        /*test the connection to the linked server. If the test is unsuccessful, the procedure throws an exception that contains the reason for the failure. */    EXECSys.sp_testlinkedserver--The following example creates a linked server named SEATTLESales and then tests the connection.  UseMaster;GOEXECsp_addlinkedserver'SEATTLESales'N'SQL Server';GOsp_testlinkedserver seattlesales;GO--------------------------------------   

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.