What are the challenges you face when working across database platforms? Take the survey
Options

Snippet Intergration

malcolm.daughtreemalcolm.daughtree Posts: 16
edited August 22, 2008 9:47AM in SQL Prompt Previous Versions
Ok, This is a biggy I know, but I have found this to be an excellent marrying of SQL Server Templates and RedGate Snippets. I use the the snippet code of 'chdr' to load this as a code header for procedures. I them press the Ctrl+Shift+M to Activate the template dialog box for SQL Server, fill in the requested inforamtion and hey Presto, a nicely formatted code block fit for any version control system.


SNIPPET CODE

/*
--*********************************************************************

****PRESS Ctrl+Shift+M to Activate****

Creation Date: <Date,Date,Enter Creation Date>
Created By: <DEVELOPER,Name,Enter Your Name>
Name: usp_<Procedure_Name, sysname, Procedure_Name>.sql
Purpose: <Full descriptive purpose,INFO,Enter Purpose>
Location: <Location,Database,Enter DB Name> database
Output Parameters:
Return Status:
Called By:
    Calls:
    Data Modifications: None Updates: None Date Author Purpose



<Date,Date,Enter Creation Date> <DEVELOPER,Name,Enter Your Name> <Full descriptive purpose,INFO,Enter Purpose>
--*********************************************************************
*/
exec spDrop_object /*Proc Name*/usp_<Procedure_Name, sysname, Procedure_Name>
go
CREATE PROCEDURE /*Proc Name*/usp_<Procedure_Name, sysname, Procedure_Name>( @a_DEBUG int = 0, /*Parameters Here*/
<@param1, Parameters, @param1&gt; <datatype_for_param1,Change as Needed , int> = <default_value_for_param1, , 0>,
<@param2, Parameters, @param2&gt; <datatype_for_param2,Change as Needed , int> = <default_value_for_param2, , 0>)
AS
/*Your code goes under here*/
$CURSOR$

/*
--*********************************************************************
USE Case
Created :<DEVELOPER,Name,Enter Your Name>
Date :<Date,Date,Enter Creation Date>

Date Author Purpose


<Date,Date,Enter Creation Date> <DEVELOPER,Name,Enter Your Name> <Full descriptive purpose,INFO,Enter Purpose>
--*********************************************************************
[Place use case in here]
EXEC usp_<Procedure_Name, sysname, Procedure_Name> <@param1, Parameters, @param1&gt; <datatype_for_param1,Change as Needed , int> = <default_value_for_param1, , 0>,
<@param2, Parameters, @param2&gt; <datatype_for_param2,Change as Needed , int> = <default_value_for_param2, , 0>)
*/

END SNIPPET CODE

CodeOn :o
CodeOn ;-)

Comments

  • Options
    I will certainly use this idea of Malcolm to get my coding to a faster track

    e.g.
    IF OBJECT_ID(N'tempdb..<TableName,TABLE,LocalTempTable>', N'U') IS NOT NULL
    BEGIN
    DROP TABLE <TableName,TABLE,LocalTempTable>
    END

    and hit Ctr-Sht-F10

    thanks malcolm,

    gr leon
    León Carpay
  • Options
    Very neat idea, thank you

    Definitely something to use and customize for
    Jerry Hung
    DBA, MCITP
Sign In or Register to comment.