首页 新闻 会员 周边 捐助

该怎么写这个存储过程

0
[待解决问题]

-- ================================================
-- Template generated from Template Explorer using:
-- Create Procedure (New Menu).SQL
--
-- Use the Specify Values for Template Parameters
-- command (Ctrl-Shift-M) to fill in the parameter
-- values below.
--
-- This block of comments will not be included in
-- the definition of the procedure.
-- ================================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author:  <Author,,Name>
-- Create date: <Create Date,,>
-- Description: <Description,,>
-- =============================================
alter PROCEDURE  Software_select
 @No bigint
AS
BEGIN
 -- SET NOCOUNT ON added to prevent extra result sets from
 -- interfering with SELECT statements.
 SET NOCOUNT ON;

    -- Insert statements for procedure here
 SELECT * from Software;
 select * from Software where No=@No
END
GO

这样写有错吗,存储过程,我想执行一个没有条件的查询,又想执行一个有条件的查询,怎么办

杀  手的主页 杀 手 | 菜鸟二级 | 园豆:213
提问于:2011-05-13 14:38
< >
分享
所有回答(3)
0

没有啊!

小小刀 | 园豆:1991 (小虾三级) | 2011-05-13 14:45
0

@No bigint = 0

---------------------------------

 select * from Software where No=ISNULL(@No,No)

改动两处,参数可空,WHERE条件变下,就OK

kkun | 园豆:20 (初学一级) | 2011-05-13 15:17
没用
支持(0) 反对(0) 杀 手 | 园豆:213 (菜鸟二级) | 2011-05-13 15:32
0

怎么没用,都不动脑想的? KKUN说的很明白  自己再想想吧! 难道非要人家把完整的代码写给你啊

头衔 | 园豆:364 (菜鸟二级) | 2011-05-13 17:04
谢谢
支持(0) 反对(0) 杀 手 | 园豆:213 (菜鸟二级) | 2011-05-14 12:53
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册