The first method:
Copy Code code as follows:
/* Create a linked server * *
exec sp_addlinkedserver ' srv_lnk ', ', ' SQLOLEDB ', ' Barcode database IP address '
exec sp_addlinkedsrvlogin ' Srv_lnk ', ' false ', NULL, ' username ', ' password '
Go
/* Query Sample * *
SELECT A.listcode
From Srv_lnk. Barcode database name. Dbo.me_listcode A, Im_barlend B
WHERE A.listcode=b.listcode
Go
/* Delete Linked server/*
exec sp_dropserver ' srv_lnk ', ' droplogins '
The second method:
Copy Code code as follows:
exec sp_configure ' show advanced options ', 1
reconfigure
EXEC Sp_co Nfigure ' Ad Hoc distributed Queries ', 1
Reconfigure
Go
select * from Product p INNER join
Opendatas Ource (' SQLOLEDB ', ' Data source=macaco-online;user id=sa;password=sa password; '). Company.dbo.Product p2
on P.PID=P2. PID
Go
exec sp_configure ' Ad Hoc distributed Queries ', 0
Reconfigure
exec sp_configure ' show advanc Ed Options ', 0
Reconfigure
Go