復制代碼 代碼如下:
truncate table TestTable
EXEC sp_configure 'show advanced options', 1; -- 開啟高級配置
RECONFIGURE
EXEC sp_configure 'Ad Hoc Distributed Queries', 1;--開啟分布式查詢
RECONFIGURE
set IDENTITY_insert TestTable on --設(shè)置 某表允許插入遞增量
INSERT INTO TestTable(ID,Date,Info )SELECT a.ID,a.Date,a.Info
FROM OPENROWSET('SQLOLEDB','V';'sa';'123456',
'SELECT * FROM TestDatabase.dbo.TestTable') AS a
set IDENTITY_insert TestTable OFF --設(shè)置 不某表允許插入遞增量
EXEC sp_configure 'Ad Hoc Distributed Queries', 0;--關(guān)閉分布式查詢
RECONFIGURE
EXEC sp_configure 'show advanced options', 0;--關(guān)閉高級配置
RECONFIGURE