ToBe

ToBe

  • NA
  • 164
  • 94.3k

Update Stored Procedure

Apr 25 2013 3:24 PM
Hi Everybody ,

I have one main stored procedure and two minor stored procedures for insertion data to the SQL DB of my system and i'm using

OTUPUT insreted.Id in my main stored procedure  where Id is the Primary field in the Details Table  .

can any body tell me how to create an update stored procedure using the same method or any way to update the 3 tables ?

 here is my stored procedures :
   
   Main Stored Procedure:


ALTER  PROCEDURE  [dbo].[sp_INSERT_REG_DETAILS]
 
  
    @SER_NO NVARCHAR (50),
    @REG_DATE DATE,
    @NAME Varchar(50),
    @RPF NVARCHAR (50),
    @ADDRESS VARCHAR(250),
    @COLG VARCHAR(50),
    @USR INT
     
  
 
AS 
 
 Set NoCount On
 
 Begin
 
 
 Insert into REG_DETAILS
 
   (
        Ser_no,Reg_date,Name,Prf,Address,Golg,User
     
   )
  
   output inserted.ID
  
 
     
   Values
       (
      
        @SER_NO,@REG_DATE,@NAME,@RPF,@ADDRESS,@COLG,@USR
             
         
          )
         
                
 End


Second stored procedure:


ALTER PROCEDURE [dbo].[sp_INSERT_TYPE]
    @ID int
    @TYPE varchar (50)
AS
BEGIN
   
   
SET NOCOUNT ON;

     Insert into [dbo].[TYPE]
          (ID,TYPE)values(@ID,@TYPE)
   
END


Third stored procedure :

ALTER PROCEDURE [dbo].[sp_AddArch]
    @ID  int
    @ST varchar (50)= NULL
AS
BEGIN
   
    SET NOCOUNT ON;

     Insert into tblarch
          (ID,stu)values(@ID,@ST)
   
END



 

Answers (2)