declare @ServerName nvarchar(600)
declare @Uid nvarchar(60)
declare @Pwd nvarchar(600)
set @ServerName='.' --数据库地址
set @Uid='sa' --用户名
set @Pwd='****' --密码
exec sp_addlinkedserver 'MyDB', '', 'SQLOLEDB', @ServerName
exec sp_addlinkedsrvlogin 'MyDB', 'false ',null,@Uid,@Pwd
go
SET IDENTITY_INSERT Menu ON
go
truncate table Menu
insert into Menu
select * from MyDB.LongForDev.dbo.Menu
go
set IDENTITY_INSERT Menu OFF
go
EXEC sp_droplinkedsrvlogin 'MyDB',null
EXEC sp_dropserver 'MyDB'