读书人

连接数据库更新处理

发布时间: 2012-02-24 16:30:39 作者: rapoo

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

读书人网 >SQL Server

热点推荐