Tuesday, August 28, 2012

Templates for New Query Window


I ran across this SQL tip a long time ago. I cannot remember where I got it form but it has made my life easier when creating scripts for other people or for when I need to store off the script as a back up. 

Credit goes to the person I learned this from. 

EDIT: I know this works for SQL2005 & SQL2008, I have not tried it on Azure or SQL2012


When I’m in SQL Server Management Studio and I click the “New Query” button, my Query Window comes up like this:

/* .sql
Purpose:
Author:
Last Edited:
Instructions:
References:
*/


/* End .sql */

Then I just press CTRL-SHIFT-M and enter the name of the script file, the purpose and so on.
I was recently asked how I have that come up every time.

Just locate the file called Sqlfile.SQL. It’s normally in:
C:\Program Files\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE\SqlWorkbenchProjectItems\Sql

Edit it to have whatever you want. If you want the replaceable parameters like I have, just put whatever you want in this format:

Don’t forget to change my name to yours in the Author line.

No comments:

Post a Comment