Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does the new stored procedure default content mean?

When I create a new stored procedure I get an initial example of a stored procedure, what does this section mean? :

CREATE PROCEDURE <Procedure_Name, sysname, ProcedureName> 
-- Add the parameters for the stored procedure here
<@Param1, sysname, @p1> <Datatype_For_Param1, , int> = <Default_Value_For_Param1, , 0>, 
<@Param2, sysname, @p2> <Datatype_For_Param2, , int> = <Default_Value_For_Param2, , 0>

..... ...

I define my stored procedure like this:

CREATE PROCEDURE HumanResources.uspGetEmployees 
  @LastName nvarchar(50), 
  @FirstName nvarchar(50)  

.....

So what does the above parameters and procedure name default syntax means? (by the way , the default text doesn't execute too).

like image 317
Rodniko Avatar asked Mar 19 '12 08:03

Rodniko


2 Answers

When you create a new stored procedure using Server Management Studio, it creates the stored procedure using a default template for you.

If you press Ctril+Shift+M you should get a nice little editor window to specify values for template parameters.

Here is a full list of SQL Server Management Studio Keyboard Shortcuts

Hope this helps..

like image 142
Kaf Avatar answered Oct 13 '22 00:10

Kaf


That markup is because it's a template. Using the example:

<Procedure_Name, sysname, ProcedureName>

The first value is the name of the parameter in the templaye (e.g. "Procedure_Name"), the 2nd is the data type expected for the value of that template parameter (e.g. "sysname") and the 3rd value is the default value for that parameter (e.g. "ProcedureName").

You can specify those template parameters by the clicking the "Specify values for template parameters" toolbar button in SSMS (has an "A" and "B" icone with arrows)

So you can create your own templates, and use that markup to specify what bits should be replaced (Ctrl+Alt+T shows the Template Explorer)

like image 45
AdaTheDev Avatar answered Oct 13 '22 00:10

AdaTheDev