1.打开跨服务器功能
exec sp_configure 'show advanced options',1
reconfigure
exec sp_configure 'Ad Hoc Distributed Queries',1
RECONFIGURE
2.关闭跨服务器功能
exec sp_configure 'Ad Hoc Distributed Queries',0
reconfigure
exec sp_configure 'show advanced options',0
reconfigure
3. 跨服务器查询
select * from
OPENDATASOURCE ('SQLOLEDB','Data Source=192.168.0.188;User ID=sa;Password=hualong2012').SoyErp.[dbo].[MA_LOT] t
4.跨服务器赋值
INSERT INTO ma_lot ( VNumber ,
VBarCode ,
VTypeCode ,
StepCode ,
Version ,
MId
)
SELECT TOP 1 VNumber ,
VBarCode ,
VTypeCode ,
StepCode ,
Version ,
MId
FROM OPENDATASOURCE ('SQLOLEDB','Data Source=192.168.0.188;User ID=sa;Password=hualong2012').SoyErp.[dbo].[MA_LOT]
5.跨服务器赋表结构
SELECT * INTO test FROM
OPENDATASOURCE('sqloledb','data source=192.168.0.188;user id=sa;password=hualong2012').SoyErp.dbo.ma_lot WHERE 1<>1
或者
SELECT TOP 0 * INTO test FROM
OPENDATASOURCE('sqloledb','data source=192.168.0.188;user id=sa;password=hualong2012').SoyErp.dbo.ma_lot