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

    SQL Prompt Hidden Gems: The SSMS Results Pane

    Every time you need to reuse the query results from SSMS, for example to populate another table, or to search for matching rows in another table, it will inevitably mean a lot of manual tweaking to the get the results into the right format. Louis Davidson uncovers three hidden Prompt gems (Open in Excel, Script as INSERT, Copy as IN clause) that can remove all this pain.

  • Article

    SQL Prompt Safety Net Features for Developers

    Ever accidentally executed code while connected to the right database but the wrong server? Phil Factor describes a few common mishaps that everyone working in SSMS will have experienced, and how SQL Prompt "Tab Magic" provides insurance against their consequences.

  • Article

    The Sins of SELECT * (BP005)

    If Prompt warns you of use of the asterisk, or 'star' (*), in SELECT statements, consider replacing it with an explicit column list. It will prevent unnecessary network load and query performance problems, and avoid problems if the column order changes, when inserting into a table.

  • Article

    How to format a set of SQL scripts using SQL Prompt

    Any database developer or DBA who spends much of their working week staring at SQL code quickly becomes set in their ways. They like to see the code laid out in a very particular way. They will struggle to look at, let alone digest and understand, code formatted in a ‘foreign’ style. It’s also rare

  • 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.