Hi,
we create a table in sql server database. how we can create a stored procedure for insert and update records in the table ?
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Eddie JackPosted Aug 21, 2011, 11:50 PM
But I Want to insert and update in a singe table with single stored procedure.
Satyapriya NayakPosted Aug 21, 2011, 1:20 AM
If this post helps you mark it as answer
Thanks
Satyapriya NayakPosted Aug 18, 2011, 1:12 AM
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