Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Newbie question on creating SP?
Message
From
01/09/2006 10:39:29
Keith Payne
Technical Marketing Solutions
Florida, United States
 
General information
Forum:
Microsoft SQL Server
Category:
Stored procedures, Triggers, UDFs
Environment versions
SQL Server:
SQL Server 2005
Miscellaneous
Thread ID:
01150360
Message ID:
01150374
Views:
23
>What is the recommended method of creating a stored procedure in SQL 2005?
>
>If open SQL Server Management Studio and go to MyDatabase -> Programmability -> Stored Procedures -> Right-click -> New Stored Procedure, I get the template. Is working from this template the most productive way of creating SP? What are other methods?
>
>Once you create a SP, how do you execute it in SQL Server Management Studio?
>
>In the SP template the CREATE PROCEDURE syntax is as following:
>
>
>CREATE PROCEDURE <Procedure_name, sysname, ProcedureName>
>
>
>Why is the ProcedureName there twice?

Dmitry,

The best way to create a stored procedure in SQL 2005 is to click on the New Query button (top left) and begin typing. If you absolutely need to use a template, drag one from the template explorer into the content pane and press Ctrl-Shift-M within the new query to bring up the template substitution dialog.

The reason that Procedure_name & ProcedureName is in there twice is because it is a placeholder for what you type into the subsitution dialog. The first Procedure_name is the substitution "variable", sysname is the datatype, and ProcedureName is the default value.

To execute the stored procedure, add a line like
EXEC Myprocedure 'Hello', 10, '20060901'
to the commented header block. Then after running the entire create script with F5, highlight the EXEC line and hit F5 again. It will run whatever is highlighted.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform