x

how to create stored procedures?

hi, i am manish kumar

how to create stored procedures in SQL server 2005, and relationship to primary and candidate key.

more ▼

asked Feb 02 '10 at 02:35 AM in Default

Manish Kumar gravatar image

Manish Kumar
1 1 1 1

(comments are locked)
10|1200 characters needed characters left

2 answers: sort voted first

To create a stored procedure use the following syntax:

Create Procedure <name> as
<your query here>

..and execute that as a query

An may I suggest that you look it up further in Books Online (The SQL Server help, reacable from inside Management Studio help menu) to get more info about such things as parameters

more ▼

answered Feb 02 '10 at 04:39 AM

Steinar gravatar image

Steinar
1.7k 3 4 6

+1 - for suggestion to refer to BOL.
Feb 02 '10 at 05:31 AM Fatherjack ♦♦
(comments are locked)
10|1200 characters needed characters left

In SQL 2005,

When you select NEW Stored procedure, it will create a template for you.

It looks like this -

CREATE PROCEDURE dbo.YOUR_STOREDPROCEDURE_NAME

-- Add the parameters for the stored procedure here

AS

BEGIN

    -- YOUR STATEMENT HERE / QUERY 
SELECT <@Param1, sysname, @p1>, <@Param2, sysname, @p2>

END

GO

more ▼

answered Feb 02 '10 at 06:25 AM

Leo gravatar image

Leo
1.6k 51 56 58

(comments are locked)
10|1200 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

New code box

There's a new way to format code on the site - the red speech bubble logo will automatically format T-SQL for you. The original code box is still there for XML, etc. More details here.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

SQL Server Central

Need long-form SQL discussion? SQLserverCentral.com is the place.

Topics:

x1933
x402

asked: Feb 02 '10 at 02:35 AM

Seen: 1000 times

Last Updated: Feb 02 '10 at 06:37 AM