--创建链接服务器
exec sp_addlinkedserver  'srv_lnk','','SQLOLEDB','远程服务器名或ip地址'
exec sp_addlinkedsrvlogin 'srv_lnk','false',null,'用户名','密码'
go--查询示例
select * from srv_lnk.数据库名.dbo.表名--导入示例
select * into 表 from srv_lnk.数据库名.dbo.表名--以后不再使用时删除链接服务器
exec sp_dropserver 'srv_lnk','droplogins'
go

解决方案 »

  1.   

    create trigger Trg_A
    on A
    for insert,update,delete
    as
    begin
        delete a from srv_lnk.B1.dbo.B1 a,deleted b where a.关键字=b.关键字
        
        insert into srv_lnk.B1.dbo.B1 select * from inserted
    end
    go
      

  2.   

    libin_ftsafe(子陌红尘) :請問要是修改呢?
      

  3.   

    通过触发器实现数据库的即时同步 
    http://blog.csdn.net/zjcxc/archive/2003/12/29/20082.aspx
      

  4.   

    SQL Server触发器中应这样理解UPDATE:删除被修改记录(记录在deleted中),并将修改之后的记录重新插入表中(记录在inserted中)。
      

  5.   

    因為我兩張表的字段只有部分相同,我想要是修改的話只更新相同的部分,如果刪除後再插入那麼可能不相同的部分倒被刪除
    另外,請解釋一下inserted在插入和修改時,其內容有什麼不同
    謝謝
      

  6.   

    Server: Msg 311, Level 16, State 1, Procedure insertwl, Line 10
    Cannot use text, ntext, or image columns in the 'inserted' and 'deleted' tables.
    Server: Msg 311, Level 16, State 1, Procedure updatewl, Line 9
    Cannot use text, ntext, or image columns in the 'inserted' and 'deleted' tables.
    55555~~怎麼辦啊,有字段類型是TEXT
      

  7.   

    你要实现的是:两个数据库中数据同步的问题,可以使用SQL的数据复制功能,或数据得导入导出功能
      

  8.   

    sxycgxj() ,謝謝你
      我要實現的是一個表中的某一部分字段同步