Today in SQL Server data query, you need to use a cross-server connection , here to record how to use the cross-server query method in SQL Server, there are the following steps.
/*
Create an intermediate database link
exec sp_addlinkedserver ' middledata ', ' ', ' SQLOLEDB ', ' database connection instance, or IP '
exec sp_addlinkedsrvlogin ' Middledata ', ' false ', NULL, ' Database connection account ', ' Database connection password '
*/
Once you have created a connection, you can query the data from the remote database in the query window of the current database
Select Top Ten * from Middledata. Database name. dbo. database table name
The format is as follows: Select Top * from MIDDLEDATA.DATABASETEST.DBO.LC_GCSG_HTCB
If you do not need this database connection, you can delete it, delete the following method:
/*
Delete
exec sp_dropserver ' middledata ', ' droplogins '
*/
Guangzhou Jing-an Technology Co., Ltd., SharePoint Professional Development, information portal, SharePoint workflow, Knowledge Base, document management and other solutions providers.
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
SQL serve querying data methods across servers