Single stored procedure to insert update and delete in sql server 2008

Check out Best Alternative to InfoPath


Here is this post we will discuss how to write a single stored procedure that will insert, update and delete in the table in Sql server 2008. Also, you can check out my previous posts on:
Below are steps for performing the common stored procedure in sql server.
Right click on a stored procedure, then add a new stored procedure. Here the stored procedure will take 5 parameters. Based on the @action parameter we will inset, update or delete the record.
Create procedure sp_InserUpdateDelete
        @id integer;
        @name varchar(20);
        @add varchar(20);
        @img varchar(20);
        @action varchar(20)
As
      if(@action=’I’)
begin
     Insert into emp_master(emp_name,emp_address,emp_image) value (@name,@add,@img)
end
    if(@action=’U’)
begin
     Update emp_master set emp_name=@name,emp_address=@add,emp_image=@img where emp_id=@id
end
      if(@action=’D’)
begin
       Delete from emp_master where emp_id=@id
end
Return
Then save the stored procedure by pressing CTRL+S where emp_master is the table name , sp_InserUpdateDelete is the procedure name.

You May Also like the Following SharePoint Online Tutorials:

About Bijay Kumar

I am Bijay from Odisha, India. Currently working in my own venture TSInfo Technologies in Bangalore, India. I am Microsoft Office Servers and Services (SharePoint) MVP (5 times). I works in SharePoint 2016/2013/2010, SharePoint Online Office 365 etc. Check out My MVP Profile.. I also run popular SharePoint web site SharePointSky.com

View all posts by Bijay Kumar →