远程数据库迁移数据

代码:

  --创建链接服务器 
exec sp_addlinkedserver   'ITSV ', ' ', 'SQLOLEDB ', '192.168.1.72' 
exec sp_addlinkedsrvlogin 'ITSV ', 'false ',null, 'sa ', '!QAZ2wsx' 

--查询示例 
 insert into [AutoData].[dbo].[AutoData_Report_Account_Item] 
 select [AccountID]
      ,[AccountCode]
      ,[AccountName]
      ,[AccountTypeName]
      ,[AccountTypeCode]
      ,[AccountTypeNameSub1]
      ,[AccountTypeCodeSub1]
      ,[AccountTypeNameSub2]
      ,[AccountTypeCodeSub2]
      ,[Dr_Cr_EN]
      ,[Dr_Cr_CN]
      ,[Unit]
      ,[IsDelete]
      ,[CreateTime]
      ,[UpdateTime] from ITSV.[P3QA].[dbo].[P3_Report_Account_Item]

--以后不再使用时删除链接服务器 
exec sp_dropserver  'ITSV ', 'droplogins ' 

http://www.cnblogs.com/OpenCoder/archive/2010/03/18/1689321.html

http://www.cnblogs.com/jokey/archive/2010/08/05/1793507.html

posted @ 2015-06-03 09:52  hongdada  阅读(385)  评论(0编辑  收藏  举报