我没有发现太大的问题,不过
你有个疏漏:
if @pub_id<>''
set @asdf='pub_id='+''''+@pub_id+''''
if @pub_minit<>''
set @asdf=@asdf+' and minit='++''''+@pub_minit+''''
if @pub_id<>'' or @pub_minit<>''
set @asdf=' where '+@asdf
既然是字符,查询的时候应该加上''
如 select * from mytable where col1='jack'
你有个疏漏:
if @pub_id<>''
set @asdf='pub_id='+''''+@pub_id+''''
if @pub_minit<>''
set @asdf=@asdf+' and minit='++''''+@pub_minit+''''
if @pub_id<>'' or @pub_minit<>''
set @asdf=' where '+@asdf
既然是字符,查询的时候应该加上''
如 select * from mytable where col1='jack'
set @asdf=rtrim(@asdf)+' and minit='+@pub_minit
set @asdf=rtrim(@asdf)+' and minit='+@pub_minit
另外,exec pubs_tj 'employee','','s'这句调用相当于:
select ... from employee where and minit=‘s’... -- 错误很显然的
---------???