Thursday, December 12, 2013

Create a stored procedure in SQL Server 2008

The following is the default template created by SSMS when selecting new stored procedure.

I'm not exactly sure why I added this entry since I'm unlikely to forget how to select a context menu, but here it is anyway.




SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

CREATE PROCEDURE <Procedure_Name, sysname, ProcedureName>
   <@Param1, sysname, @p1> <Datatype_For_Param1, , int> = <Default_Value_For_Param1, , 0>,
   <@Param2, sysname, @p2> <Datatype_For_Param2, , int> = <Default_Value_For_Param2, , 0>
AS
BEGIN

   SET NOCOUNT ON;

   SELECT <@Param1, sysname, @p1>, <@Param2, sysname, @p2>
END
GO






No comments:

Post a Comment