6 February 2017

1 Comment

6 February 2017

1 Comment

Quick SQL Prompt tip – restore your tabs, even if you closed them by mistake

It’s sometimes too easy to close SQL Server Management Studio (SSMS) without saving your work. It’s also easy to get rid of tabs and scripts that you later wish you had back. SQL Prompt can help with both these problems.

Take a look at the Options for SQL Prompt and you’ll find a set of options under Tabs > History:

SQL Prompt tab history 1

You can enable or disable tab history according to your own preferences. Once it’s enabled, you get a number of behaviors that can prove extremely helpful.

First up, you can restore on launch all the tabs you had open when you last closed SSMS. Reopening your tabs helps ensure that you see the same work as you did when you closed it. Further, if you didn’t save that tab, no worries because tab history has all the T-SQL code, just as it was before you closed it, covering for you in the event of a problem. Tab history can also reconnect the tabs to the databases they were connected to prior to closing them.

There is also a literal history of the tabs on your system. You can use the keyboard shortcut designated above, Ctrl+Q, or you can use a button installed on the button bar to get a history of the tabs you had open in your SSMS environment:

SQL Prompt tab history 2

This shows the tabs currently open, but you can see that there is a listing under All tabs for closed tabs. By clicking on Closed, I get a list of all the tabs going back in time that I’ve had open on this SSMS instance:

SQL Prompt tab history 3

This allows me to track down previously opened tabs, even if I didn’t save them. I also get the ability to search across these tabs. For example, if I know that one of my previously opened tabs contained scripts for setting up Extended Event sessions within Azure SQL Database, I can simply type session in the search window:

SQL Prompt tab history 4

I get the tab, the scripts, its location on the disk and the last time I closed it. I can then browse through the script by scrolling on the right or browse the scripts by scrolling through them on the left.

Never again should you worry about forgetting to save a script or losing track of where it was on your disk. With SQL Prompt tab history, you’ll be protected and assisted when managing your tabs.

If you’re not a SQL Prompt user, download a free trial and see how much more productive you can be writing code every day.

Like this? Share it with other SQL professionals using the social sharing buttons below. Simply tweet: I’ve just read @ GFritchey’s blog on restoring tabs with #SQLPrompt – see the #SuperSQLTip at http://rd.gt/2khoRyZ.

Tools in this post

SQL Prompt

Write, format, and refactor SQL effortlessly in SQL Server Management Studio and Visual Studio.

Find out more

Share this post.

Share on FacebookShare on Google+Share on LinkedInTweet about this on Twitter

You may also like

  • Article

    Templates and Snippets in SSMS and SQL Prompt

    Phil Factor explains the uses and limitations of native SSMS templates and snippets, and then demonstrates the extra versatility that SQL Prompt snippets provide.

  • Article

    Avoid T-SQL Technical Debt using SQL Prompt Code Analysis

    SQL Prompt can help prevent the build-up of technical debt in your database code. It alerts the team immediately to issues that might not prevent your code from working as expected, but could eventually cause problems with performance, or maintenance, or even security.

  • Article

    Quick SQL Prompt tip – script objects as ALTER in two clicks

    Working in a large database can be difficult at times. While many of us might learn the meanings and definitions of most objects, it’s easy to forget the exact ways in which some objects work, or what the behavior is in certain calls. This is one place where having tools that assist you like SQL

  • Article

    SQL Prompt Code Analysis: Avoid using the ISNUMERIC Function (E1029)

    Avoid using the IsNumeric() function, because it can often lead to data type conversion errors, when importing data. On SQL Server 2012 or later, use the Try_Convert() or Try_Cast() function instead. On earlier SQL Server versions, the only way to avoid it is by using LIKE expressions.

  • University

    Take the SQL Prompt course

    This Redgate University course takes you from installation all the way up to getting the most out of the advanced operations in SQL Prompt. As well as autocompleting your code, you’ll learn how SQL Prompt can help you with code formatting, object renaming, code analysis, and other useful tip and tricks.

  • Forums

    SQL Prompt Forum

    Write, format, and refactor SQL effortlessly

  • JBrune

    Where is the tab information stored on disk? I ask because every once in a blue moon it does not restore all the closed and it would be nice to be able to restore at least some of what’s been missed.