declare @condition varchar(1000)
set @condition='asd3werw'
if isnull(@condition,'')<>''
exec('select * from tb where (数值类型)值>0'+@condition)
else
select * from tb
set @condition='asd3werw'
if isnull(@condition,'')<>''
exec('select * from tb where (数值类型)值>0'+@condition)
else
select * from tb
看联机帮助丛书中declare cursor的例子!
理解这个就懂得怎么用了!
insert into @t select 1,'a',3,'t'
union all select 2,'a',7,'t'
union all select 3,'a',9,'t'
union all select 4,'a',4,'t'
union all select 5,'b',14,'t'
union all select 6,'b',13,'t'
union all select 7,'c',13,'t'
union all select 8,'c',13,'t'
union all select 9,'c',15,'t'
declare @li_id int
set @li_id=0
select * from @t t where t.id>(case @li_id when 0 then -t.id else 0 end)