SQL Server 2005 procedure to Create stored procedure

15 pts.
Tags:
SQL 2005
SQL Server 2005
SQL Server stored procedures
SQL stored procedures
sir,plz tell me the procedure from strating that how to create stored procedure

Software/Hardware used:
sql server 2005

Answer Wiki

Thanks. We'll let you know when a new response is added.

A stored procedure is a set of one or more SQL statements that are stored together in database. To create a stored procedure use CREATE PROCEDURE statement. To use the stored procedure send a request for it to be executed. When server recieves the request, it executes the stored procedure.
When creating, remember the followings…..
1. Stored procedure is one or more SQL statements that have been compiled and stored with database.
2. In addition to SELECT statement, a stored procedure can contain other SQL statements such as INSERT,UPDATE,DELETE.
3. Stored procedure can improve database performance because the SQL statements in each procedure are only compiled and optimized the first time they are executed.
4. A trigger is a special type of procedure that executes when rows are inserted, updated or deleted from table.
5. A user defined function(UDF) is a special type of procedure that can return a value or a table.
For Example. First create database from SQL Server Management studio in Administrative mode. Now Expand Microsoft SQL server 2005 database folder > expand database folder > Right click on Tables folder and click on the New Table option > and design database structure as per given fields or as ur requirement
Now create Procedure….
set ansi_nulls on
go
set quoted_identifier on (optional)
go
create procedure <procedurename>
Name_emp varchar(50)
as
begin
select empid, empname, empdoj, empdob
from <tablename> where Name_emp = <something> order by empid
end
go
CAUTION: Be care of the syntax.
Now execute this thru Sql Server Management Studio > Execute Stored Procedure and select the procedure name !
For more info: please link here (though it is based on 2008, but still it helps to clear ur concept) http://msdn.microsoft.com/en-us/library/ms345415.aspx

Discuss This Question:  

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following