在存储过程如何执行@strSql中的语句?在线等!正确立刻结帖!
niukl 2003-09-11 04:10:32 我想实现一个分各种条件查询的查询语句:比如:select * from table1 where 条件1 and 条件2 and 条件3 and 条件4 ......
我原想有一个变量:
declare @strSql char(300)
set @strSql='select * from table1'
if ....
begin
set @strSql=@strS1l+ '条件1'
end
if ....
begin
set @strSql=@strS1l+ '条件2'
end
.
.
.
最后用一个语句执行@strSql,想法不知可行吗?不行的话,如何才能实验呀?