Query templates

  • When my team or I open a new query in ssms we'd like to see a documentation header to remind us to complete the docs.

    Something only the lines of:

    /*

    Name:

    Version:

    Description

    Notes

    Change log

    Test

    */

    I've created a Template via Template Browser (on the View menu) but I'd rather set the New Query command to open this template rather than the empty query.

    Any ideas if this is possible?

  • Try this:

    http://blog.sqlauthority.com/2014/11/29/sql-server-customization-of-new-query-in-sql-server-management-studio/

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • template functionality in the paid SSMS plugin ssmstoolspack.com does that.(~40 bucks as I remember)

    it also is parameterized for variables.

    for example, my template looks like this:

    -- Created By: |CurrentWinUserName|

    -- Create Date: |CurrentDateInYMD| |CurrentTime|

    -- Description:

    -- SET XACT_ABORT ON

    -- BEGIN TRAN

    -- COMMIT TRAN

    -- ROLLBACK TRAN

    and each new window has this format: note the variable substitutions.

    -- Created By: mydomain\lizaguirre

    -- Create Date: 2016-05-19 15:13:35.542

    -- Description:

    -- SET XACT_ABORT ON

    -- BEGIN TRAN

    -- COMMIT TRAN

    -- ROLLBACK TRAN

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply