首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

连接数据库更新处理,

2012-02-24 
连接数据库更新处理,求助!!!!想做触发器插入表时获取城市名称,然后更新declare@Citychar(10)select@CityC

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

热点排行