日期:2014-05-17 浏览次数:20463 次
declare @test table(data int,dt varchar(20)) declare @tmp table(sn varchar(2)) declare @i int set @i=1 while @i<60 begin insert into @tmp values(cast(right(100+@i,2) as varchar(2))) set @i=@i+1 end set @i=1 while @i<60 begin if @i<>5 and @i<>16 insert into @test values(@i*@i,'2012-08-25 14:'+cast(right(100+@i,2) as varchar(2))) set @i=@i+1 end select * from ( select a.sn sn1,b.sn sn2,b.data,b.dt from @tmp a left join (select right(dt,2) sn,* from @test) b on a.sn=b.sn )t where sn2 is null --where datediff(hh,b.dt+'.000',getdate())=1
------解决方案--------------------