日期:2014-05-17 浏览次数:20443 次
begin declare @id int declare @id2 int declare youbiao cursor for select id from Db_TranRD where ExitTime is null and carid is not null open youbiao fetch next from youbiao into @id while(@@fetch_status=0) begin print @id set @id2='select trid from Db_Alarm where trid=@id' if @id2 is null begin print @id2 fetch next from youbiao into @id end end close youbiao deallocate youbiao end
begin declare @id int declare @id2 int declare youbiao cursor for select id from Db_TranRD where ExitTime is null and carid is not null open youbiao fetch next from youbiao into @id while(@@fetch_status=0) begin print @id select @id2=trid from Db_Alarm where trid=@id if @id2 is null begin print @id2 fetch next from youbiao into @id end end close youbiao deallocate youbiao end --你应该是这个意思
------解决方案--------------------
果然是押输了,最近好勤快。
------解决方案--------------------
declare @id2 int
set @id2='select trid from Db_Alarm where trid=@id'
消息 245,级别 16,状态 1,第 2 行
在将 varchar 值 'select trid from Db_Alarm where trid=@id' 转换成数据类型 int 时失败。