当前位置: 代码迷 >> Sql Server >> 计划任务失误
  详细解决方案

计划任务失误

热度:53   发布时间:2016-04-27 10:50:39.0
计划任务出错
SQL code
begindeclare @id intdeclare @id2 intdeclare youbiao cursor for select id from Db_TranRD where ExitTime is null and carid is not nullopen youbiaofetch next from youbiao into @idwhile(@@fetch_status=0)beginprint @id set @id2='select trid from Db_Alarm where [email protected]'  if @id2 is null  begin  print @id2fetch next from youbiao into @idendendclose youbiao deallocate youbiaoend

提示 消息 245,级别 16,状态 1,第 10 行
在将 varchar 值 'select trid from Db_Alarm where [email protected]' 转换成数据类型 int 时失败。

------解决方案--------------------
探讨
SQL code
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(@@……

------解决方案--------------------
SQL code
begindeclare @id intdeclare @id2 intdeclare youbiao cursor for select id from Db_TranRD where ExitTime is null and carid is not nullopen youbiaofetch next from youbiao into @idwhile(@@fetch_status=0)beginprint @id select @id2=trid from Db_Alarm where [email protected]  if @id2 is null  begin  print @id2fetch next from youbiao into @idendendclose youbiao deallocate youbiaoend--你应该是这个意思
------解决方案--------------------

果然是押输了,最近好勤快。
------解决方案--------------------
declare @id2 int
set @id2='select trid from Db_Alarm where [email protected]'

消息 245,级别 16,状态 1,第 2 行
在将 varchar 值 'select trid from Db_Alarm where [email protected]' 转换成数据类型 int 时失败。