日期:2014-05-18 浏览次数:20401 次
create procedure query(@xh char(6)=xh) as if not exists(select * from xsb where xh=@xh) print '学号不存在' else begin select * from(select xsb.xh,xm,kcm,cj from xsb join cjb join kcb on cjb.kch=kcb.kch on xsb.xh=pcjb.xh) as temp(xh,xm,kcm,cj) where xh=@xh end execute query '081102'
--默认*为全部 create procedure query(@xh char(6) = '*') as if isnull(@xh,'*') = '*' begin select xsb.xh,xsb.xm,kcb.kcm,cjb.cj from xsb,cjb,kcb where cjb.kch = kcb.kch and xsb.xh = cjb.xh end else begin select xsb.xh,xsb.xm,kcb.kcm,cjb.cj from xsb,cjb,kcb where cjb.kch = kcb.kch and xsb.xh = cjb.xh and xsb.xh = @xh end