日期:2014-05-18  浏览次数:20498 次

连接数据库更新处理,求助!!!!
想做触发器插入表时获取城市名称   ,然后更新
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


问题是通过查询分析器执行无回应长时间等待,触发器里插入失败
单独执行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=20998

update   Einfo   set   Area=@City
where   ID=438551
可以正常通过

------解决方案--------------------
碰到过这样的问题,是通过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 ')