一个关于select存储过程的问题

coolskyboy 2010-12-13 11:01:43
我需要编写一个select存储过程 有几个参数 UserID UserName UserPassword UserSort ,当4个null当作参数的时候,返回所有表中的内容 ,当不为null的时候 根据给出的参数 来返回符合条件的内容。 请知道的教下我谢谢
...全文
38 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
coolskyboy 2010-12-13
  • 打赏
  • 举报
回复
谢谢了 下午搞的时候把and 搞成了or 老不对 现在终于没问题了
百年树人 2010-12-13
  • 打赏
  • 举报
回复
select *
from tb
where userid=isnull(@userid,userid)
and username=isnull(@username,username)
and userpassword=isnull(@userpwd,userpassword)
and usersort=isnull(@usersort,usersort)

22,209

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server 疑难问题
社区管理员
  • 疑难问题社区
  • 尘觉
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧