You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: SSMS/SSMS_Tips/README.md
+14-16Lines changed: 14 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -112,7 +112,6 @@ Also you can activate multi line mode with `Shift + Alt` keys and using keyboard
112
112
113
113
114
114
<aid="6"></a>
115
-
a>
116
115
## Script Table and Column Names by Dragging from Object Explorer
117
116
Save keystrokes by dragging
118
117
Drag the `Columns` folder for a table in to auto-type all column names in the table in a single line.
@@ -122,7 +121,6 @@ Drag the `Columns` folder for a table in to auto-type all column names in the ta
122
121
123
122
<aid="7"></a>
124
123
## Disable Copy of Empty Text
125
-
<aid="8"></a>
126
124
127
125
- Select a block of text to copy;
128
126
- Move the cursor the place where you want to paste the code;
@@ -132,7 +130,7 @@ Drag the `Columns` folder for a table in to auto-type all column names in the ta
132
130
This behavior can be disabled in SSMS: go to `Tools > Options > Text Editor > All Languages > General > 'Apply Cut or Copy Commands to blank lines when there is no selection'` and uncheck the checkbox.
133
131
134
132
135
-
<aid="9"></a>
133
+
<aid="8"></a>
136
134
## Client Statistics
137
135
When you enable that option for your session, SQL Server Management Studio will give you more information about the client side processing of your query.
138
136
@@ -149,7 +147,7 @@ The Time Statistics additionally shows you the following information:
149
147
- Wait Time on Server Replies
150
148
151
149
152
-
<aid="10"></a>
150
+
<aid="9"></a>
153
151
## Configure Object Explorer to Script Compression and Partition Schemes for Indexes
154
152
Is this index compressed or partitioned?
155
153
@@ -163,7 +161,7 @@ You can make sure you’re aware when indexes have compression or are partitione
163
161
- Click OK
164
162
165
163
166
-
<aid="11"></a>
164
+
<aid="10"></a>
167
165
## Using GO X to Execute a Batch or Statement Multiple Times
168
166
The `GO` command marks the end of a batch of statements that should be sent to SQL Server for processing, and then compiled into a single execution plan.
169
167
By specifying a number after the ‘GO’ the batch can be run specified number of times. This can be useful if, for instance, you want to create test data by running an insert statement a number of times. Note that this is not a Transact SQL statement and will only work in Management Studio (and also SQLCMD or OSQL). For instance the following SQL can be run in SSMS :
@@ -180,7 +178,7 @@ This will run the insert statement 10 times and therefore insert 10 rows into th
180
178
In this case this is a simpler alternative than creating a cursor or while loop.
181
179
182
180
183
-
<aid="12"></a>
181
+
<aid="11"></a>
184
182
## SSMS Template Replacement
185
183
One under-used feature of Management Studio is the template replacement feature. SSMS comes with a library of templates, but you can also make your own templates for reusable scripts.
186
184
@@ -189,7 +187,7 @@ In your saved .sql script, just use the magic incantation to denote the paramete
189
187
Then, when you open the `.sql` script, you hit `CTRL + Shift + M`, and SSMS will give you a pop-up to enter your replacement values
190
188
191
189
192
-
<aid="13"></a>
190
+
<aid="12"></a>
193
191
## Color coding of connections
194
192
SQL Server Management Studio has the capability of coloring the bar at the bottom of each query window, with the color dependent on which server is connected.
195
193
This can be useful in order to provide a visual check of the server that a query is to be run against, for instance to color code production instances as red, development as green and amber as test.
@@ -198,13 +196,13 @@ To add a color bar when connecting to the server click on the Options button in
198
196
Select the check box towards the bottom of the window and use the ‘Select…’ button to choose a color.
199
197
200
198
201
-
<aid="14"></a>
199
+
<aid="13"></a>
202
200
## SQLCMD mode
203
201
Switching on SQLCMD mode enables a number of useful extra scripting style commands in SSMS.In particular you can use it to change to the connection credentials within the query window, so that you can run a query against multiple servers from the same query window.
204
202
There are more details of how to do this here: [Changing the SQL Server connection within an SSMS Query Windows using SQLCMD Mode](http://www.sqlmatters.com/Articles/Changing%20the%20SQL%20Server%20connection%20within%20an%20SSMS%20Query%20Windows%20using%20SQLCMD%20Mode.aspx)
205
203
206
204
207
-
<aid="15"></a>
205
+
<aid="14"></a>
208
206
## Script multiple objects using the Object Explorer Details Windows
209
207
Individual database objects, such as a table or stored procedure, can be scripted within SSMS by right clicking on the object within Object Explorer and selecting the appropriate item in the drop down menu.
210
208
However if you have a lot of objects to script that can quickly become time consuming.
@@ -215,7 +213,7 @@ A list of all tables appears in the Object Explorer Details window.
215
213
Select the tables you want to script (using the Control key if necessary) and then right click and select which script option you want – e.g. to create a table create script for all tables
216
214
217
215
218
-
<aid="16"></a>
216
+
<aid="15"></a>
219
217
## Registered Servers / Central Management Server
220
218
If you have a lot of servers then re-entering the details in Object Explorer every time you start SSMS can be frustrating and time consuming.
221
219
Fortunately there are two facilities within SSMS that enable these details to be entered just once and “remembered” each time you open up SSMS.
@@ -233,7 +231,7 @@ Central Management Server are similar to Registered Servers but with some differ
233
231
A significant limitation with CMS is that the CMS server itself can’t be included in the list of servers.
234
232
235
233
236
-
<aid="17"></a>
234
+
<aid="16"></a>
237
235
## Splitting the Query Window
238
236
The query window in SSMS can be split into two so that you can look at two parts of the same query simultaneously.
239
237
Both parts of the split window can be scrolled independently. This is especially useful if you have a large query and want to compare different areas of the same query.
@@ -242,22 +240,22 @@ To split the window simply drag the bar to the top right hand side of the window
242
240
The splitter bar allows you to view one session with two panes. You can scroll in each pane independently. You can also edit in both the top and bottom pane
243
241
244
242
245
-
<aid="18"></a>
243
+
<aid="17"></a>
246
244
## Moving columns in the results pane
247
245
It may not be immediately obvious but you can switch columns around in the results pane when using the grid view, by dragging the column headers and dropping them next to another column header.
248
246
This can be useful if you want to rearrange how the results are displayed without amending the query, especially if you have a lot of columns in your result set.
249
247
This works only for one column.
250
248
251
249
252
-
<aid="19"></a>
250
+
<aid="18"></a>
253
251
## Generating Charts and Drawings in SQL Server Management Studio
254
252
You don't have to settle for T-SQL's monochrome text output. These stored procedures let you quickly and easily turn your SELECT queries' output into colorized charts and even computer-generated art.
255
253
To turn your own data into a line, column, area, or bar chart using the Chart stored procedure, you need to design a SELECT query that serves as the first parameter in the stored procedure call.
256
254
257
255
Detailed Article and code here: [Generating Charts and Drawings in SQL Server Management Studio]
258
256
259
257
260
-
<aid="20"></a>
258
+
<aid="19"></a>
261
259
## Additional Connection Parameters
262
260
One such change SSMS got for free is the connection resiliency logic within the SqlConnection.Open() method.
263
261
To improve the default experience for clients which connect to Azure SQL Database, the above method will (in the case of initial connection errors / timeouts) now retry 1 time after sleeping for 10 seconds. These numbers are configurable by properties called ConnectRetryCount (default value 1) and ConnectRetryInterval (default value 10 seconds.)
@@ -269,12 +267,12 @@ ConnectRetryCount=0
269
267
```
270
268
271
269
272
-
<aid="21"></a>
270
+
<aid="20"></a>
273
271
## Working with tabs headers
274
272
You can view [SPID](https://docs.microsoft.com/en-us/sql/t-sql/functions/spid-transact-sql) in tabs header, quickly script open containing folder or copy script file path.
275
273
276
274
277
-
<aid="22"></a>
275
+
<aid="21"></a>
278
276
## Hiding tables in SSMS Object Explorer
279
277
1. You can actually hide an object from object explorer by assigning a specific extended property:
0 commit comments