Login or Sign Up to become a member!
LessThanDot Sit Logo

LessThanDot

Data Management

Less Than Dot is a community of passionate IT professionals and enthusiasts dedicated to sharing technical knowledge, experience, and assistance. Inside you will find reference materials, interesting technical discussions, and expert tips and commentary. Once you register for an account you will have immediate access to the forums and all past articles and commentaries.

LTD Social Sitings

Lessthandot twitter Lessthandot Linkedin Lessthandot friendfeed Lessthandot facebook Lessthandot rss

Note: Watch for social icons on posts by your favorite authors to follow their postings on these and other social sites.

Your profile

    Search

    XML Feeds

    Google Ads

    « Returning a value inserted in a table with a newsequentialid() default on a uniqueidentifier columnAttending PASS Summit 2011? Want Lunch? And Free Career Advice? I Have Just The Event... »
    comments

    SQL Server Management Studio is the de facto tool for working with SQL Server. But its default options may not always be the best way for you to work. After working with it for years, I’ve come up with a list of my favorite features.

    (Secret: This is also my way of recording this so that the next time I need to set up a new PC, I just have to come back here.)

    Part I: The Options Menu

    In SSMS, go to Tools > Options.

    > Environment
    >> Keyboard: Here you can set up “Query shortcuts”. By default, sp_help, sp_who and sp_lock are there. I’ve added things like sp_whoisactive. Are there other queries you use regularly? Set up shortcuts here, to save yourself the trouble of having to open a script file, or (gasp) typing them each time.

    > Text Editor
    >> All Languages
    >>> General
    >>>> Word wrap: I’m not sure where I would be without this setting. Who wants to scroll back and forth constantly?

    >>>> Line numbers: it’s just what it means. Go from this:

    to this:

    >>> Transact-SQL
    >>>> IntelliSense: turn on IntelliSense to have SSMS help you complete field names, function names, and more. Users of Visual Studio will be used to this functionality. Note: this will only work in SSMS 2008 and above, against SQL Server 2008 and greater databases.

    >>> Editor Tab and Status Bar
    This can be broken into two sections.

    >>>> Status Bar Content and Status Bar Layout and Colors: control how that bar that is at the bottom of query execution window (by default) appears.

    >>>> Tab Text: controls what information appears in the tab at the top of a query.

    > Query Results
    >> SQL Server: Here, I can choose the default location for saving my results, if I don’t want to save it in the location Microsoft specifies.

    >>> Results to Grid: Here, I like to choose a few non-standard options.

    “Include column headers when copying or saving the results” means just that. When I right-click a result-set, copy it, then paste it, the column headers will go with it.

    “Display results in a separate tab” – when I execute my query, instead of the results being in the lower half, they are on a second tab. I can even choose to switch to that automatically. This is especially useful for presentations.

    Instead of this:

    I see this:

    > SQL Server Object Explorer
    >> Commands: In Object Explorer, you can right-click a table or view and choose to select or edit the top X rows. Here, you can set the values for these options.

    >> Scripting: there is a wealth of options here that will turn things on or off when you right-click an object and choose to Script To…

    Some of my favorites: Include descriptive headers, Script USE database, Include IF NOT EXISTS clause, and Schema qualify object names. Take the time to look through this list and understand what you can turn on and off in SSMS.

    > Designers
    >> Table and database designers: I uncheck the “Prevent saving changes that require table re-creation” option.

    Part II: Object Explorer

    There are a couple cool things you can do with Object Explorer that I find people are unaware of.

    First, when you are writing a query, especially against an older database that doesn’t have IntelliSense support, you can drag table, view, column and stored procedure names to the query pane instead of typing them.

    Dragging the “Columns” across to the query pane will produce this:

    Second, you can filter the items you see in a database. The little blue funnel at the top of Object Explorer will help you do this.

    Here, I’m going to filter on the “Person” schema.

    My results are much easier to read. This isn’t a huge deal in AdventureWorks, but when you get into databases with hundreds or thousands of objects, this is very handy.

    And third, when you run a script and have an error, most times you can double-click it to be taken to the line that generated the error. (That one? Hard to demonstrate with a screenshot. Next plan: video blogging!) But, give it a try.

    Part III: Must-Have Third-Party Add-Ins

    SSMS Tools Pack - http://www.ssmstoolspack.com/

    This free add-in extends the functionality of SSMS. A lot. Some of its features that I love:

    Window Connection Coloring – want to have a green bar at the top of queries against development servers, yellow on QA, and red on production? Just set it up.

    New Query Template – want to have the same text appear in every new query you open up? Me too. Create a template.

    Want to have your query history saved to a text file or a database table? It’s all here.

    And that’s just scratching the surface. Download this tool!

    Extended Events Manager - http://extendedeventmanager.codeplex.com/

    Are you using Extended Events yet? You should be. Sure, the down side is that there is no GUI for it (yet). However, this tool starts to bridge the gap. You can view event sessions, start and stop them, drop them, and script out operations.

    Making the Most of Your Tools

    The defaults provided by Microsoft are not always the most efficient, or the most helpful to you. Explore the settings in SSMS and make it work for you!

    About the Author

    User bio imageJes Schultz Borland is a Consultant with Brent Ozar PLF, and a Microsoft SQL Server MVP. She holds an AAS - Programmer/Analyst degree, and has worked with SQL Server since 2007, focusing on Reporting Services and day-to-day administration. She is an active member of PASS, Director of Communication for MADPASS, founder of Tech on Tap, and a LessThanDot.com blogger. She's a frequent presenter at user groups, SQL Saturdays, and other community events. She is also an avid runner and chef.
    Social SitingsTwitterLinkedInLTD RSS Feed
    InstapaperVote on HN

    24 comments

    Comment from: SQLDenis [Member] Email
    SQLDenis Nice tips...BTW SSMS also has the coloring tab thing (it doesn't always honor it but it has been fixed for Denali)

    You can find it under Options-- Use Custom Color from the connections dialog

    In terms of SSMS toolpack I like the snippets, the formatting of SQL and also the fact that you can script out the query results the most

    09/22/11 @ 07:01
    Comment from: David Howard [Visitor] Email · http://davidbrycehoward.com
    David Howard Nice post.
    I never noticed the filter for Object Explorer, could definitely be useful sometimes.
    09/22/11 @ 07:14
    Comment from: bonskijr [Member] Email
    bonskijr How about server organisation using Registered Servers option? This comes very handy with multiple servers.

    If only "Central Management Servers" allows sql server authentication as opposed to Windows auth only.

    Keyboard shortcuts imo is mostly underutilised by devs Nice list :)
    09/22/11 @ 07:43
    Comment from: Naomi Nosonovsky [Member]
    Naomi Nosonovsky Thanks for sharing, I think I'll adjust a few of options I haven't paid attention before
    09/22/11 @ 08:24
    Comment from: Naomi Nosonovsky [Member]
    Naomi Nosonovsky I have a question - may be you know the answer. When you type something in SSMS the intellisense sometimes makes it much harder to write - say, it always expands partition to PARTITION_FRAGMENT... and also when I type t for my alias if I don't put t. quickly enough it gives me tallying (name of another table in the database). I'm wondering if it's possible to instruct intellisense to not come into the way...
    09/22/11 @ 11:14
    Comment from: Yukon1975 [Visitor] · http://mikeessen.wordpress.com
    Yukon1975 One that you don't have that I love is the keyboard shortcut to update Intellisense CNT-SHIFT-R. Takes a moment and reloads the Intellisense cache.
    09/22/11 @ 11:17
    Comment from: SQLDenis [Member] Email
    09/22/11 @ 12:02
    Comment from: Andy Paul [Visitor] Email
    Andy Paul Great post! I only wish I'd have read this months ago... I also have the same problem as Naomi Nosonovsky. I often have to query a table with a column in it called 'country_id'. Every time I want to do a COUNT(*), Intellisense 'corrects' it to country_id :-)

    The Query shortcuts is a great one. I thought it was only for SPs!
    09/22/11 @ 13:27
    Comment from: genomon [Member]
    genomon Alas! It seeme that Intellisense is not available in 2005? Definitely not in the text editor node (T-SQL is not even listed).
    09/22/11 @ 13:34
    Comment from: SQLDenis [Member] Email
    SQLDenis genomon,

    Correct, Intellisense is SQL Server 2008 and up...unless you use something like Red Gate SQL Prompt, that will also work on SQL Server 2005 (
    09/22/11 @ 14:25
    Comment from: chopstik [Member]
    chopstik I'll ditto Denis's last comment. I found Red Gate SQL Prompt to be a very useful feature with SQL Server 2005. Unfortunately, I lost it when I last had to switch machines and company wasn't willing to pony up to renew it. *sigh*
    09/22/11 @ 16:55
    Comment from: Jes Schultz Borland (grrlgeek) [Member]
    Jes Schultz Borland (grrlgeek) Naomi/Andy - I don't know of a way to alter Intellisense settings. I run into the same problem, though. However, I'll take what I can get from it.

    I miss having SQL Prompt. It was more customizable, it was easy-to-use, and it worked against all versions of SQL Server.
    09/22/11 @ 20:11
    Comment from: Jim Murphy [Visitor] · http://www.sqlwatchmen.com
    Jim Murphy Great tips and post. I never noticed the one about the keyboard shortcuts to my common queries! Thanks for showing me this one.
    09/23/11 @ 07:55
    Comment from: SQLArcher [Member] Email
    SQLArcher Also something not a lot of people know is; in the Object Explorer Details pane (press F7 to bring it up if it isn't already) - you can shift + click multiple objects and delete it or script it where possible(stored procs, views, tables, etc).
    09/23/11 @ 12:18
    Comment from: Aaron Bertrand [Visitor] · http://sqlblog.com/blogs/aaron_bertrand/
    Aaron Bertrand Don't forget about Plan Explorer and its SSMS add-in...
    http://www.sqlsentry.net/plan-explorer/sql-server-query-view.asp
    09/23/11 @ 12:39
    Comment from: Neil Hambly [Visitor] · http://sqlblogcasts.com/blogs/NeilHambly
    Neil Hambly Great article.. if you haven't tried it .. I personally move the status bar from [Bottom] to [Top] .. especially usefull when using color coding for connections.. as it get's right in the eyeline and I find that a better position (well for me anyway)
    09/25/11 @ 05:32
    Comment from: Rob Farley [Visitor] · http://sqlblog.com/blogs/rob_farley
    Rob Farley Nice post. :)

    I prefer to NOT turn on the Column Headers bit (unless I'm on a pre-2008 SSMS), because I can right-click on the grid and choose whether I want to include the headers or not.

    Also worth noting that the shortcuts will append whatever you have selected. So if you have a tablename selected when you hit Ctrl-1, it'll run 'sp_help tablename' - which is fine except that it doesn't put quotes around it. So it'll work if it's in the dbo schema, but not if it's in anything else.

    I've often asked for tweaks to some of these things, like being able to configure those shortcuts to support %1 options, and being able to configure to be prompted for an alias when dragging columns (so I can say 'd' and have those Department columns all appear as d.whatever, or to configure to have them on separate lines. There are Connect items for some of these...

    Another feature you might want to consider for future lists is holding down Alt when you select text. Try it some time... it's really handy when you're about to use Replace (if you're formatting your code okay - again, handier still if you could get the column-dragging to use new-lines).

    But yeah - nice post. I dread to think how long it took with all those screenshots.

    Rob
    09/25/11 @ 19:39
    Comment from: Amit Banerjee [Visitor] · http://troubleshootingsql.com
    Amit Banerjee Nice post. There are lots of tricks available in SSMS to make your work easier. Thanks for putting all this together, Jes.
    09/28/11 @ 23:58
    Comment from: SQL-Admin [Visitor] · http://www.kodyaz.com
    SQL-Admin Hello Naomi,
    The keyboard shortcuts is one of the tricks that I use frequently, I configure for SSMS instances so that it prevents repeatitive coding on the query editor
    11/02/11 @ 08:34
    Comment from: Don Kolenda [Visitor] · http://donkolenda.blogspot.com
    Don Kolenda Great post, Jes!
    11/22/11 @ 13:34
    Comment from: Richard Lewis [Visitor] · http://Www.gogorichie.com
    Richard Lewis Awesome post it's instantly one my favorites, one i'll forward on to people. Keep up them coming !!!!!
    12/10/11 @ 14:45
    Comment from: server management [Visitor] · http://www.wotarticle.com/
    server management Very helpful and informative post! Great work!
    12/19/11 @ 06:24
    Comment from: Peter [Visitor]
    Peter I would like to add a recommendation for SQL Prompt if you do a lot of ad-hoc TSQL. It's worth the money, though better if your company pays for it.

    As for the connection coloring, SSMS tends not to notice if you change connections for the window. I've been bitten by this before and thought I was on a different server. I didn't do horrible things, but still a nasty surprise. SSMS Tools handles this correctly. I think it's been fixed by MS for 2012 and may have been fixed in 2008R2, but verify instead of taking my vague recollection as fact. :)
    01/17/12 @ 13:55
    Comment from: Naomi Nosonovsky [Member]
    Naomi Nosonovsky One extra nice trick with SSMS is in this article
    Find Scripts Quickly in SQL Server Management Studio

    I used it as it helps me to find my extra scripts (outside of SSMS My Projects area).
    01/26/12 @ 09:22

    Leave a comment


    Your email address will not be revealed on this site.

    Your URL will be displayed.
    (Line breaks become <br />)
    (Name, email & website)
    (Allow users to contact you through a message form (your email will not be revealed.)