Hi,
we create a table in sql server database. how we can create a stored procedure for insert and update records in the table ?
Stored procedure
3 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Satyapriya NayakRank #47 · 31.5K reputationPosted Aug 17, 2011, 9:12 PM EDT
Please see the below code
-------------------To display records from database------------
CREATE PROCEDURE display
AS
select * from student
------------------- To insert records from database------------
CREATE PROCEDURE insert1
(@sid varchar(50),@sname varchar(50),@smarks int,@saddress varchar (50),@year varchar(50))
AS
insert student(sid,sname,smarks,saddress,year) values (@sid,@sname,@smarks,@saddress,@year)
------------------- To update records from database------------
CREATE PROCEDURE update1
(@sid varchar(50),@sname varchar(50),@smarks int,@saddress varchar (50),@year varchar(50))
AS
update student set sname=@sname,smarks=@smarks,saddress=@saddress,year=@year where sid=@sid
------------------- To delete records from database------------
CREATE PROCEDURE delete1
(@sid varchar(50))
AS
delete from student where sid=@sid
Thanks
If this post helps you mark it as answer
Satyapriya NayakRank #47 · 31.5K reputationPosted Aug 20, 2011, 9:20 PM EDT
If this post helps you mark it as answer
Thanks
Eddie JackRank #2,520 · 556 reputationPosted Aug 21, 2011, 7:50 PM EDT
But I Want to insert and update in a singe table with single stored procedure.