SQL Server tips and tricks
To help you learn about a few of the capabilities and features of Microsoft SQL Server 2016, we have compiled our favorite tips and tricks.
If you have any questions, contact us.
Use the Cycle Clipboard Ring feature
SQL Server Management Studio (SSMS) stores multiple copies of the code that you copy and cut in the clipboard. SSMS maintains a history of this code so that you can paste it into other code. This feature is known as Cycle Clipboard Ring.
To use it, click Edit > Cycle Clipboard Ring, or use the keyboard shortcut Ctrl+Shift+V.
Use code snippets
The code snippets feature helps you write code quickly. Code snippets provide you with templates for specific tasks. Use the following steps to insert a snippet template and change the values:
In SQL Server Management Studio (SSMS), right-click Query Window.
Select Insert Snippet.
Select the snippet category from the list that is displayed.
Select the task from the list that is displayed.
Change the values and run the code.
Debug a SQL script
You can use the following methods to debug a SQL script:
Open or write the script and then press Alt+F5, which opens the debug interface.
Click the Debug button in the SQL Editor tool bar to open the debug interface.
Classify server categories by using colors
In SQL Server Management Studio (SSMS), you can specify the colors of the status bars for the servers. For example, you can specify red for production servers, yellow for test servers, and green for development servers.
Use these steps to categorize servers by color:
While connected to the server, click Option in the Connect to Database Engine dialog box.
Select the Connection Properties tab.
Click Use Custom Color and select the color you want.
You can quickly get the metadata and properties for objects.
In the query window, select the object and press Alt+F1. The metadata and properties of the selected objects are shown.
Note: The result type depends on the selected object type. If no object is selected, a list of all objects in the database is returned.
Use the Surround With snippet
The Surround With snippet is a template that you can use as a starting point for enclosing a set of Transact-SQL statements in a BEGIN, IF, or WHILE block.
Use the following steps to insert a Surround With snippet:
In the query window, select the code that you want to enclose with the snippet around.
Right-click and select Surround With.
Select the type of block that you want to use. For example, select Code Snippet for While loop.
The code is then enclosed with the selected block type.
©2020 Rackspace US, Inc.
Except where otherwise noted, content on this site is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License