导航
  • 主页
  • 基础类
  • 应用实例
  • 新技术前沿

存储过程的小错误,散分(显示是isnull附近的错误)

chenminer 2003-12-23 09:11:25
--------------------------------------------------
-- GetTaskInfoByMultiCondition 按多个信息返回任务信息(是否打印,任务单编号,项目名称)
--------------------------------------------------
CREATE PROCEDURE GetTaskInfoByMultiCondition
@condition_1 nvarchar(50), --taskid
@condition_2 nvarchar(50), --ifprinted
@condition_3 nvarchar(50), --project_item_id
@condition_4 nvarchar(50) --exam_date
AS
SET NOCOUNT ON
declare @sql nvarchar(400)
set @sql='SELECT task_id,project_name,consign_firm,exam_date,printed_date,ifprinted FROM grosstask WHERE ifexam=1 '
exec(@sql+isnull(@condition_1,'')+' '+isnull(@condition_2,'')+' '+isnull(@condition_3,'')+' '+isnull(@condition_4,''))

RETURN 0
--------------------------------------------------
--返回一个记录集
------------------------------------------------
GO
...全文
68 点赞 收藏 1
写回复
1 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
DigJim 2003-12-23
--------------------------------------------------
-- GetTaskInfoByMultiCondition 按多个信息返回任务信息(是否打印,任务单编号,项目名称)
--------------------------------------------------
CREATE PROCEDURE GetTaskInfoByMultiCondition
@condition_1 nvarchar(50), --taskid
@condition_2 nvarchar(50), --ifprinted
@condition_3 nvarchar(50), --project_item_id
@condition_4 nvarchar(50) --exam_date
AS
SET NOCOUNT ON
declare @sql nvarchar(400)
set @sql='SELECT task_id,project_name,consign_firm,exam_date,printed_date,ifprinted FROM grosstask WHERE ifexam=1 '


set @condition_1=isnull(@condition_1,'')
set @condition_2=isnull(@condition_2,'')
set @condition_3=isnull(@condition_3,'')
set @condition_4=isnull(@condition_4,'')

exec(@sql+@condition_1+@condition_2+@condition_3+@condition_4)

RETURN 0

--------------------------------------------------
--返回一个记录集
------------------------------------------------
GO
回复
发动态
发帖子
MS-SQL Server
创建于2007-09-28

3.2w+

社区成员

MS-SQL Server相关内容讨论专区
申请成为版主
社区公告
暂无公告