编程论坛
注册
登录
编程论坛
→
SQL Server论坛
[求助]这样的存储过程怎么写
reniking
发布于 2007-05-22 19:32, 670 次点击
想写个存储过程,需要几个传个参数,这几个参数都可以是int类型,也可以是空
如果传进来的某个参数是数字,取出相应字段等于参数值的行
如果传进来空,相应字段可以为任意值
这样的功能怎么实现呀?大家帮忙!谢谢
5 回复
#2
从小到大
2007-05-22 20:48
create proc xxxxx
@a as int=null,
@b as int=null,
@c as int=null
as
select * from table
where (
a=@a
or @a is null)
and (
b=@b
or @b is null)
and (
c=@c
or @c is null)
#3
niitstar
2007-05-25 18:28
支持楼上的说法,不过好象少了begin...end哈
#4
从小到大
2007-05-25 20:27
不一定要Begin end 吧 可以省略的哦
#5
niitstar
2007-05-25 21:48
哦,这样啊,以前我都用了的,我搞哈看,不好意思哈
#6
niitstar
2007-05-25 21:52
果然是这样的啊,不好意思哈。。。。
1