想做触发器插入表时获取城市名称 ,然后更新
declare   @City  char(10) 
 select @City=City   from EAinfo where Id=20998update  [10.0.10.2].database1.dbo.Einfo set Area=@City
where ID=438551
问题是通过查询分析器执行无回应长时间等待,触发器里插入失败
单独执行update  [10.0.10.2].database1.dbo.Einfo set Area="ssss"
where ID=438551
可以正常通过。执行本地数据库
declare   @City  char(10) 
 select @City=City   from EAinfo where Id=20998update Einfo set Area=@City
where ID=438551
可以正常通过

解决方案 »

  1.   

    已经建立“链接服务器”了要不然是无法执行update  [10.0.10.2].database1.dbo.Einfo set Area="ssss"
    where ID=438551

    问题是加了变量批量执行时就不行了
      

  2.   

    碰到过这样的问题,是通过EXEC解决。declare @City char(10)
    select @City=City from EAinfo where Id=20998--update [10.0.10.2].database1.dbo.Einfo set Area=@City where ID=438551
    exec ('update [10.0.10.2].database1.dbo.Einfo set Area=''' + @City + ''' where ID=438551')
      

  3.   

    这样会报错@City 提示未定义 
    如果
    exec('
    declare   @City  char(10) 
     select @City=City   from EAinfo where Id=20998update  [10.0.10.2].database1.dbo.Einfo set Area=@City
    where ID=438551')
    又是相同结果,执行无回应
      

  4.   

    Limpire(昨夜小楼) 是我们看清楚,谢谢了!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!