SQL Server link service configuration

Source: Internet
Author: User
A. Link to the SQL Server:

1. Use the ODBC Microsoft ole db Provider

EXEC sp_addmediaserver 'Alias ', '', 'msdasql', NULL, NULL, 'driver = {SQL Server}; SERVER = remote name; UID = user; PWD = password ;'
Go
Exec sp_add1_srvlogin @ rmtsrvname = 'aliased ', @ useself = 'false', @ locallogin = 'sa', @ rmtuser = 'sa ', @ rmtpassword = 'Password'
2. Use SQL Server's Microsoft OLE DB Provider

Exec sp_addlinkedserver @ server = 'Alias ', @ provider = 'sqlodb', @ srvproduct = '', @ datasrc = 'remote server name'
Exec sp_addjavassrvlogin @ rmtsrvname = 'wzb', @ useself = 'false', @ locallogin = 'sa ', @ rmtuser = 'sa', @ rmtpassword = 'Password'

3. operation data
Select * from alias. Database Name. dbo. Table Name
Insert database name. dbo. Table Name select * from alias. Database Name. dbo. Table Name
Select * into database name. dbo. New table name from alias. Database Name. dbo. Table Name
Go

Example 1: Create a linked Server named S1_instance1 on the SQL Server instance, which uses the Microsoft ole db provider of SQL Server.

EXEC sp_addmediaserver @ server = 's1 _ instance1 ', @ srvproduct = '', @ provider = 'sqloledb', datasrc = 's1 \ instance1'

Example 2: Create a linked server
EXEC sp_addmediaserver 'xiaoming', '', 'msdasql ', NULL, NULL, 'driver = {SQL Server}; SERVER = 192.168.0.1; UID = sa; PWD = 123 ;'
Create a connection Server login ing
Exec sp_addmediasrvlogin @ rmtsrvname = 'xiaoming', @ useself = 'false', @ locallogin = 'sa ', @ rmtuser = 'sa', @ rmtpassword = '2016'
Go
-- Query data
Select * from xiaoming. schooladmin. dbo. agent

-- Delete the link Server login ing and link Server:
Exec sp_droplinkedsrvlogin 'xiaoming', 'sa'
Exec sp_dropserver 'xiaoming'

Note:

SET IDENTITY_INSERT [database. [owner.] {table} {ON | OFF}. Therefore, you cannot SET this attribute by connecting to the server.
Into also has this problem: select * into xiaoming. northwind. dbo. tt from xiaoming. northwind. dbo. tt

B. Set the linked server to Access the Access database

Use the Microsoft ole db provider for Jet. In this example, create a linked server named test.

This example assumes that Microsoft Access and the example Northwind database have been installed, and the Northwind database resides in C :\.
USE master
GO
-- To use named parameters:
EXEC sp_addmediaserver @ server = 'test', @ provider = 'Microsoft. Jet. OLEDB.4.0 ', @ srvproduct = 'ole DB Provider for Jet ',
@ Datasrc = 'C: \ Northwind. mdb'
GO
-- OR to use no named parameters:
USE master
GO
EXEC sp_addmediaserver 'test', 'ole DB Provider for Jet ', 'Microsoft. Jet. OLEDB.4.0', 'c: \ Northwind. mdb'
GO
Data Query
Select * from test... table name

Related Article

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.