带参数存储过程

set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go

 

 


ALTER PROCEDURE [dbo].[Save_Note_New]
    @note_id int output,
    @master_id nvarchar(max),
    @master_table nvarchar(50),
    @note_type nvarchar(20),
    @note nvarchar(max),
    @add_date datetime,
    @authorpersonid int,
    @note_wh nvarchar(50)
   
AS
  declare @signname nvarchar(50)
BEGIN
  BEGIN TRANSACTION tran_note_new
  Save Transaction tran_note_new

  select @signname=last_name+' '+first_name from person where person_id=@authorpersonid
  if @note_id=0
    begin
      insert into [note] (master_id,master_table_name,note_content,note_type,sign_name,author_id,add_date,note)
            values(@master_id,@master_table,@note,@note_type,@signname,@authorpersonid,@add_date,@note_wh)
      select @note_id=(@@identity)
    end
  else
    begin
      update [note] set note_content=@note,sign_name=@signname,author_id=@authorpersonid,update_date=getdate(),add_date=@add_date,note=@note_wh where note_id=@note_id
    end
   
IF ( @@ERROR <> 0 )
  BEGIN 
     ROLLBACK TRANSACTION tran_note_new
  END
ELSE
  BEGIN
    COMMIT TRANSACTION tran_note_new
  END    
IF ( @@TRANCOUNT > 0 )
  BEGIN
    ROLLBACK TRANSACTION tran_note_new
  END
select @note_id  
END

 

 

 

 

 

 

 

 

 

 

 

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值