SQL cross-Server Query

Source: Internet
Author: User
Select. *, B. * From OpenRowSet ('msdasql ', 'driver = {SQL Server}; server = 119.254.245; uid = sa; Pwd = abc123_kxr', mall_master.dbo.product) as a, kxr_products B -- where, tom is the remote server name, and stores is the table in the local database pubs. Note that if the number of records in the two tables is different, a table will generate completely duplicate rows, -- the number of rows in the table with the longest record set is insert into DBO. kqmx_200704select * From OpenRowSet ('msdasql ', 'driver = {SQL Server}; server = 192.168.1.253; uid = sa; Pwd =', one. DBO. kqmx_200704) 1. Assume that the local server is 192.168 . 0.1, remote server 192.168.0.2. 2. Create a user on the 192.168.0.2 server: User, password: 000 3. Execute the following statement on the 192.168.0.1 server: exec sp_add1_server 'srv _ lnk ', '', 'sqloledb ', '2017. 168.0.2 'exec sp_add1_srvlogin 'srv _ lnk ', 'false', null, 'user', '000' go 3. The following is an example of database query for local access to 192.168.0.2: select * From srv_lnk. database Name. DBO. table name 4. Delete the linked server exec sp_dropserver 'srv _ lnk ', 'droplogins' 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.