sql server
am a fresher i know how to create a table,inserting table and deleting table but i don't know how to create a stored procedure please help me..........
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.
Santosh YadavPosted Feb 20, 2013, 1:14 PM
student (table name) and fields are :
1). student_id
2). student_name
3). student_age
now you want to create a stored procedure to insert records into table then.
Syntax :
create proc usp_studentInsert
(
@studentid varchar(10),
@student_name varchar(50),
@student_age varchar(5)
)
as
insert into student(student_id,student_name,student_age)
values(@studentid,@student_name,@studentage);
Note :
Here, @studentid,@student_name,@studentage are the parameters which you have to pass when you will use this procedure to insert data into table.
Satyapriya NayakPosted Feb 20, 2013, 11:15 AM
Advantages of the stored procedure
Create table student (sid varchar(50),sname varchar(50),smarks int,saddress varchar (50),year varchar(50))
--------------------------
CREATE PROCEDURE display
AS
select * from student
-----------
CREATE PROCEDURE insert
(@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)
---------------------
CREATE PROCEDURE update
(@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
-------------
CREATE PROCEDURE delete
(@sid varchar(50))
AS
delete from student where sid=@sid
Refer
http://www.mssqltips.com/sqlservertutorial/160/sql-server-stored-procedure/
http://csharp-station.com/Tutorial/AdoDotNet/Lesson07
http://www.codeproject.com/Articles/179481/Code-First-Stored-Procedures
http://www.codeproject.com/Articles/414/Tutorial-on-Extended-Stored-Procedures-for-MS-SQL
SaqiPosted Feb 20, 2013, 9:13 AM
there are plenty of references on youtube which you can see how to use references and forms i strongly recommend you to check first videos with practice.
thanks