You should create a standard comment format at the beginning of your T-SQL codes such as the below example. You can automate adding a standard comment header when you open a new Query window.
If you don’t want a standard comment block another option it so include frequently used T-SQL statements such as the below commands.
So if I use the second example, when I open a new query window in SSMS I get these commands every time as shown below.
To automate the comment/T-SQL in all new query windows, you have to modify the SQLFile.sql file which is located in:
- On 32-bit machine "C:\Program Files\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE\SqlWorkbenchProjectItems\Sql" folder.
- On 64-bit machine "C:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE\SqlWorkbenchProjectItems\Sql" folder.
Once you find the file, you can edit the SQLFile.sql with any text editor (i.e. notepad) and add your own standard comment format or T-SQL code and save the file. Then whenever you open a new Query window you will see the comments/T-SQL that you entered into the SQLFile.sql file.
Note that you must have the proper permission to edit SQLFile.sql. I used Notepad and used the "Run as administrator" option to edit and save the file. This just depends on the security that was setup on your desktop. Also, since this file is saved locally each person that wants this has to do this on thier machine.
Ref: http://www.mssqltips.com
No comments:
Post a Comment