日期:2014-05-17 浏览次数:20913 次
drop table #tb
declare @str char(24),@string nvarchar(100)
set @str = '000000000111011111100000'
set @string = '1点,2点,5点,6点,8点,18点,13点,24点'
create table #tb(id int identity(1,1),val char(1))
while(LEN(@str) > 0)
begin
insert into #tb select SUBSTRING(@str,1,1)
set @str = SUBSTRING(@str,2,len(@str)-1)
end
declare @hour int,@hourVal char(1)
set @string = REPLACE(@string,'点','')
while(LEN(@string) > 0)
begin
if CHARINDEX(',',@string) = 0
set @string = @string + ','
set @hour = REPLACE(SUBSTRING(@string,1,CHARINDEX(',',@string)),',','')
select @hourVal = val from #tb where id = @hour
if @hourVal = '1'
print CONVERT(varchar(10),@hour)+'点需要执行'
else
print CONVERT(varchar(10),@hour)+'点不需要执行'
set @string = SUBSTRING(@string,LEN(@hour)+2,LEN(@string)-1)
end