复制代码 代码如下:
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 –设置 某表允许插入递增量
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 –设置 不某表允许插入递增量
exec sp_configure ‘ad hoc distributed queries’, 0;–关闭分布式查询
reconfigure
exec sp_configure ‘show advanced options’, 0;–关闭高级配置
reconfigure