How to write the store procedure for Insert,Delete and Update the datas into the table in SQL


Here i explianed how to write the stored procedures in SQL for inserting,Updating and Deleting the the data's into the table. Following this article we discuss more in the sql procedures and if you have any queries dont hesitate to ask.

Hi,
By using the below code we get an clear idea for to insert the data in SQL table
through procedures.

I have a table which have four columns [ID int set identity(1,1),Name varchar(50),PhoneNo int,State varchar(50)]

For Insert the datas---------------------------------

  

create procedure procname1
@Name varchar(50),
@PhoneNo int,
@State varchar(50)
AS
Insert into tablename(Name,PhoneNo,State)
Values(@Name,@PhoneNo,@State)
Return




For Update the datas---------------------------------
  

create procedure procname2
@ID int,
@Name varchar(50),
@PhoneNo int,
@State varchar(50)
AS
Update table tablename set Name=@Name,PhoneNo=@PhoneNo,State=@State
Where ID=@ID
Return




For Delete the datas---------------------------------
  

create procedure procname3
@ID int
AS
Delete from tablename where ID=@ID
Return




Happy Coding friends i hope you get an clear idea in store procedures by the
above small examples


Comments

No responses found. Be the first to comment...


  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: