如何使用存储过程检索created_date_time和created_by

时间:2017-12-18 08:54:56

标签: sql-server stored-procedures

我创建了存储过程,名称是cmtprocedure.i为insert表写存储过程以及如何为这个存储过程编写select查询。如何检索注释,created_date_time,updated_date_time,created_by,updated_by?

CREATE PROCEDURE [dbo].[cmtprocedure]
@cmt_Id int = null,
@comments nvarchar(MAX)=null,
@ques_ans_id int=null,
@created_date_time datetime=null,
@updated_date_time datetime=null,
@created_by int=null,
@updated_by int=null,
@Action varchar(100)=null

AS BEGIN

 if @Action = 'insert' 

BEGIN

insert into comments(comments,ques_ans_id,created_date_time,updated_date_time,created_by,updated_by)
    values
    (@comments,@ques_ans_id,@created_date_time,@updated_date_time,@created_by,@updated_by)

END

BEGIN

 select * from comments where comments=@comments and created_date_time=@created_date_time and updated_date_time=@updated_date_time and created_by=@created_by and updated_by=@updated_by 

END

END

0 个答案:

没有答案