exec sp_addlinkedserver ‘srv_new‘,‘‘,‘SQLOLEDB‘,‘ip地址 ‘
exec sp_addlinkedsrvlogin ‘srv_new‘,‘false‘,null,‘账户‘,‘密码‘
go
BEGIN TRY
BEGIN TRANSACTION tra
TRUNCATE TABLE dbo.AccountInfo;
SET IDENTITY_INSERT dbo.AccountInfo ON
INSERT INTO dbo.AccountInfo
( id,Name , pwd , status , isdelete , master , serverId , version , hostUrl , platform , postUrl , firstStart , lstHero , lstwife , lstson , datestart )
(SELECT [Id] ,[Name] ,[pwd] ,[status] ,[isdelete] ,[master] ,[serverId] ,[version] ,[hostUrl] ,[platform] ,[postUrl] ,[firstStart] ,[lstHero] ,[lstwife] ,[lstson] ,[datestart] FROM srv_new.TestHuangShang.dbo.accountinfo )
SET IDENTITY_INSERT dbo.AccountInfo OFF
PRINT ‘success‘
COMMIT TRANSACTION tra
END TRY
BEGIN CATCH
PRINT ‘rerror‘
ROLLBACK TRANSACTION tra
//及时释放
END CATCH exec sp_dropserver ‘srv_new‘, ‘droplogins‘