create proc ec
as
begin
declare @i int
declare @count int
declare @a int
declare @time varchar(12)
declare @timeyear varchar(12)
select @i=1
select @count='select count(*) from zzzz'
while @i<=@count
begin
set @time='select convert(varchar(12),completedatetime,108) from zzzz where Exchangecellid='+@i
set @timeyear='select convert(varchar(12),completedatetime,105) from zzzz where Exchangecellid='+@i
if @time='00:00:00'
set @a='select Ondutylogid from T_OnDutyLog where convert(varchar(12),ondutydatetime,105)='+@timeyear+'and ondutytype='+'晚班'+' and ondutyno like '+'%新业务室%'
else
set @a='select ondutylogid from T_ondutylog where convert(varchar(12),ondutydatetime,105)='+@timeyear+' and ondutytype='+'白班'+' and ondutyno like '+'%新业务室%'
end if
'update zzzz set ondutylogid=@a'
set @i=@i+1
endSQl语句如上...
报错为..在应使用条件的上下文(在 'set' 附近)中指定了非布尔类型的表达式。
就是set @i=@i+1这句..
高手帮下忙啊..感激!
as
begin
declare @i int
declare @count int
declare @a int
declare @time varchar(12)
declare @timeyear varchar(12)
select @i=1
select @count='select count(*) from zzzz'
while @i<=@count
begin
set @time='select convert(varchar(12),completedatetime,108) from zzzz where Exchangecellid='+@i
set @timeyear='select convert(varchar(12),completedatetime,105) from zzzz where Exchangecellid='+@i
if @time='00:00:00'
set @a='select Ondutylogid from T_OnDutyLog where convert(varchar(12),ondutydatetime,105)='+@timeyear+'and ondutytype='+'晚班'+' and ondutyno like '+'%新业务室%'
else
set @a='select ondutylogid from T_ondutylog where convert(varchar(12),ondutydatetime,105)='+@timeyear+' and ondutytype='+'白班'+' and ondutyno like '+'%新业务室%'
end if
'update zzzz set ondutylogid=@a'
set @i=@i+1
endSQl语句如上...
报错为..在应使用条件的上下文(在 'set' 附近)中指定了非布尔类型的表达式。
就是set @i=@i+1这句..
高手帮下忙啊..感激!
select @time=convert(varchar(12),completedatetime,108) from zzzz where Exchangecellid=@i其他的类推
报错..关键字 'select' 附近有语法错误。
'update zzzz set ondutylogid=@a'
---------------------------------------
楼主是不是VB写习惯了 怎么还有 end if 的
create proc ec
as
begin
declare @i int
declare @count int
declare @a int
declare @time varchar(12)
declare @timeyear varchar(12)
select @i=1
select @count= count(*) from zzzz
while @i<=@count
begin
select @time =convert(varchar(12),completedatetime,108), @timeyear = convert(varchar(12),completedatetime,105) from zzzz where Exchangecellid=@i
if @time='00:00:00'
update zzzz set ondutylogid =(select Ondutylogid from T_OnDutyLog where convert(varchar(12),ondutydatetime,105)= @timeyear and ondutytype='晚班' and ondutyno like '%新业务室%') where ExchangeCellID=@i
else
update zzzz set ondutylogid =(select ondutylogid from T_ondutylog where convert(varchar(12),ondutydatetime,105)=@timeyear and ondutytype='白班' and ondutyno like '%新业务室%') where ExchangeCellID=@i
set @i=@i+1
end
end
已经解决了..谢谢大家!