Presentation is loading. Please wait.

Presentation is loading. Please wait.

SQL SERVER MANAGEMENT STUDIO

Similar presentations


Presentation on theme: "SQL SERVER MANAGEMENT STUDIO"— Presentation transcript:

1 SQL SERVER MANAGEMENT STUDIO
PRODUCTIVITY TIPS FOR SQL SERVER MANAGEMENT STUDIO November 2016 Bogdan Curcă, Senior Data Warehouse Developer

2 SUMMARY Chapter 1 Options menu Chapter 2
Object explorer / query window Chapter 3 View menu Chapter 4 New in SSMS 2016 Chapter 5 Free 3rd party tools

3 Chapter 1 Options menu

4 Options menu Keyboard shortcuts for queries Tools -> Options -> Environment -> Keyboard Scripting settings (that don’t come as default) Tools -> Options -> Sql Server Object Explorer -> Scripting Keyboard shortcuts for queries You can set up handy shortcuts like ‘select count(*)’, ‘select top 10 * from’ then all you have to do to perform the specified select from a table is to select it and press the associated shortcut. (Sql 2000 and above) Scripting settings Govern the way scripting is handled in SSMS. Exemplify by scripting a table with indexes and / or partitioned table before and after the modifications. Some useful scripting settings which don’t come default, are: “script indexes” – also include indexes (all other indexes beside the PK) in the table’s scripts “Script partition schemes” – also includes the partition schema where the table is created on and the partitioning criteria “Script triggers” – script the triggers associated to a table “Generate scripts for dependent objects” – generate scripts for all the objects related to the one scripted. (>= 2008) Since talking about scripting, show “Generate Scripts” – generate scripts for multiple objects at a time (for instance, the ones included in the current release). The “Advanced” tab options can override the scripting options set into “Tools -> Options -> Sql Server Object Explorer -> Scripting”, only for the current scripting session. Generate script : Right click any database -> Tasks -> Generate scripts Text editor Word Wrap + Show visual glyphs for Word Wrap – perform only vertical scrolling from now on, since the horizontal scrolling is “resolved” by Word Wrap; Line numbers also comes in handy for debugging purposes (Sql Server 2008 R2 and above)

5 Object explorer / query window
Chapter 2 Object explorer / query window

6 Object explorer / query window
Sql Server Import & Export wizard Object Explorer Details (F7) Code snippets (SSMS 2012 and above) Alternative – Template Browser  Sql Server Import & Export wizard Very useful for quick data import / export from a source to a destination, for instance from an Excel file / flat file to a database, allowing mapping input and output columns. The tool generates an SSIS package which can be run on the fly or saved locally or in msdb, in case you need some advanced transformations in SSIS, via Sql Server Data Tools. Usage: Right click on any database, Tasks -> Import / Export data (2008 and above) Object Explorer Details F7 Select multiple objects to script or delete; Show additional properties like (right click on header bar): Data Space Used Index Space Used Row Count Sql Server 2008; Count(*) in Sql Server 2012 Code snippets (Sql 2012 and above). Right click on the query window -> Insert Snippets / Surround With (or Ctrl + K, Ctrl X for snippets / Ctrl + K, Ctrl + S for Surround With) Custom snippets folder can be a Shared Folder, so that the snippets are accessible by all team members. Alternative: Template Browser (you can add your own templates): Quickly create most commonly used objects in a Sql Server database; you can also define your own templates for your generic scripts that accept different parameters. Very useful when you need to create a specific object in the database and you can’t remember its syntax right away. Using the example of a standard template, you can easily create your custom template. The button “Specify Values for Template Parameters” allows the replacement of parameters (Ctrl + Shift + M). Usage: View -> Template Browser (Ctrl + Alt + T). (Sql Server 7.0 -> Sql Server > …) Use custom color for query window status bar (Sql Server 2008 and above)

7 Chapter 3 View menu

8 View menu Solution explorer – Sql Server scripts project – group related files (Visual Studio style) –connections, script files, documentation files, etc. Use custom color for query window status bar Create a project to group related files Create a project to store together related T-SQL scripts or Analysis Services Scripts. For instance, you can create Sql Scripts for data manipulation within a specific project, you can also store various documentation files into “Miscellaneous” folder, or you can simply create a Sql Scripts project storing your most commonly used scripts, in order to access them faster and in an organized manner. Usage: View –> Solution Explorer (Ctrl + Alt + L); Right click on Solution -> Add -> New Project -> Sql Server Scripts / Analysis Services Scripts. To open SSMS always with the project items, you can do a trick – create a shortcut of the Project / Solution file – it will open SSMS with the project / solution opened. (Sql Server >)

9 Chapter 4 New In SSMS 2016

10 New in SSMS 2016 Live Query Statistics Quick launch
Pin query windows frequently used; show pinned tabs in a separate row Starting with Sql Server 2016, SSMS comes as a separate installation package and has the options to check for updates periodically. Live Query Statistics sys.dm_exec_query_profiles Dynamic Management View introduced in SQL Server > has now a graphical implementation, with progress indicators for each plan node, that are updated real time and also an overall progress indicator The operators are linked through dotted lines, instead of full arrows, as in execution plan. Each operator has below it information about how much time passed from its start and the percentage between actual no. of rows and the estimated no. of rows that it outputted. To get the percentage of completion for each operator, we must hover with the mouse over the specific operator. The Tooltip window for each node is refreshed live with information – the percentage of work done and no. of rows that the operator outputted. As stated in the documentation, “This feature is primarily intended for troubleshooting purposes. Using this feature can moderately slow the overall query performance.”. Current limitations: - Natively compiled stored procedures are not supported Quick launch – we don’t have to remember each setting’s path – just type a setting / feature name and watch the results being narrowed down to the correspondent path of that option -> that you can click and launch It has 4 categories: Most Recently Used, Menus, Options and Open Documents. Pin query windows frequently used – We can pin the query windows containing the most important queries – we use frequently. Tools -> Options -> Environment -> Tabs and Windows -> Pinned tabs -> Show pinned tabs in a separate row (of write “Pin” in quick launch) “Maintain Pin Status if document is Removed from well” – works when re-opening SSMS.

11 Chapter 4 Free 3rd party tools

12 Free 3rd party tools (1 of 2)
SentryOne Plan Explorer Plan Diagram – more advanced graphical way of presenting an execution plan Plan Tree / Top operators– details about each node puts aside estimated vs actual indicators Sql Sentry Plan Explorer - provides a nice way, more graphical than standard feature of SSMS of presenting an execution plan – helps finding the bottleneck in an execution plan Starting 2 weeks ago, Sql Sentry decided to also give the extra features from Plan Explorer Pro as free! Plan Diagram - offers a nice, graphical visualization of the execution plan Space is better used in the graphical plan of plan explorer that in SSMS – the vertical scrolling is minimized You can easily see the worst performing note Split costs – by I/O, by CPU, or combined Line width by No. of rows / Data size that passed through each node Plan Tree / Top operations - Contain details about each node. You can see side by side Est vs. Actual no. of rows that flowed through each node – a difference between them could indicate a statistics outdated. Other problems may be due to a bad estimation which leads to spill in tempdb, parallelism problems when the work was not evenly distributed across all the threads due to different causes, etc. Statement list with missing index recommendations – if clicking on a certain row, the corresponding object from the graphical plan is highlighted – if there is an index recommendation, by right clicking on the node in the graphical plan, we got to see the actual statement for index creation. Possibility to generate an actual execution plan from a query that is run from within Plan Explorer – also returning statistics of the execution (Table I/O, durations, etc.) – the query will be run on sql server, but the results will be discarded. (2008 -> for sure, for older don’t know / guarantee).

13 Free 3rd party tools (2 of 2)
SSMS Boost Editor History - Keep a history of the queries written / executed Fatal Actions Guard Result Grid Aggregates Find Columns in Result Grid / Find Data in result Grid Script grid data -> Generate insert data - metadata population Format Sql Code Go to Object in Object Explorer / Go to definition (script object) SSMS Boost Productivity tool that implement nice features like: - Editor History - Keep a history of the query text written in a query window; you can configure its behavior from SSMSBoost-> Settings-> “Editor Contents History” Very useful, especially when you forget to save your query for later use or in case of power outage. Different version of the same script can be compared by using a tool like WinMerge (needs to be configured first!) For Privacy reasons, this feature is not active by default. - Fatal Actions Guard – Block / ask for permission when performing Update / Delete / Truncate without an Where clause Result grid aggregates -quickly interact with the result grid and display aggregates of the selected area of interest (sum, count, etc.) - Find columns / Data in result grid Find data in results grid - Find specific terms in the Grid results (no need to export to excel for that!) – Search for a specific term directly in the result set from the Grid – Right click inside the grid -> Find in Results Grid; Similar is Find Column in Result grids – useful for tables with many columns, to quickly find what you are looking for. - Script grid data -> Generate insert data - metadata population (for a static metadata, when preparing the script for upper environment migration, for instance) - Format Sql Code, based on a set of rules – very useful when dealing with a large amount of unformatted code - Go to Object in Object Explorer / Go to definition (script object) Locate object in the Object Explorer (Ctrl + F2) (go to object)– from the query window, select an identifier, then press the “Locate Object” button to find it in Object Explorer Script object at cursor position (Go to definition)– F2 or right click – script object at cursor position Optional (if there is time): - “Auto” button – Synchronize current query window with the Sql Server instances they belong to, in Object Explorer - Code regions -Very useful for logically grouping blocks of code within a stored procedure, for instance, or grouping and collapsing an older block of commented code, that needs to be further stored for future reference. -- prepare an example with a large stored procedure, using different regions to store different logically split blocks of code - Windows connection coloring (Preferred Connections) for each Sql Server instance / database Very useful in a multi environment workspace; Additional messages (that would appear in a small rectangle in the bottom right of the screen, having specified color) could be configured, to emphasize, for instance, a Production instance - Quick connections switch - Quickly navigate through different Sql Server instances / + databases of the current instance Works with “Preferred connections” . (2008 and above)

14 Help yourself to be more productive…

15 [ KEY POINTS ] KEYBOARD SHORTCUTS FOR QUERIES
Goal: Speed-up your work! SQL SERVER IMPORT & EXPORT WIZZARD Goal: Easy data import – export from various sources SSMS BOOST Goal: : Improve productivity!

16 Thank YOU questions ?


Download ppt "SQL SERVER MANAGEMENT STUDIO"

Similar presentations


Ads by Google