How to Create A Stored Procedure for Insert and Update Data ?

Total Post:73

Points:517
 341  View(s)
Ratings:
Rate this:


  1. Post:282

    Points:2008
    Re: How to Create A Stored Procedure for Insert and Update Data ?

    //---------Create a procedure for Add new record--------//

    CREATE Proc ContactCreateOrUpdate
    
    @ContactID int,
    @Name varchar(50),
    @Mobile varchar(50),
    @Address varchar(50)

    AS
        BEGIN
           IF(@ContactID=0)
         Begin
             insert into Contact(Name,Mobile,Address) values(@Name, @Mobile, @Address)
         END

         Else
             Begin
             update Contact Set Name=@Name, Mobile=@Mobile, Address=@Address
          where ContactID=@ContactID
         END
       END


Answer