How do we recover the unsaved query window in SQL Server Management Studio?
This is a simple tip to recover your unsaved query window in SSMS.
As a SQL server professional, most of us will work closely with SSMS in a daily basis.At times, we forget to save our work in the management studio and for some reason if the query window closes/SSMS crashes, we will be in a position of “lost everything”. You may be questioned on your best practises. Here is a way to recover the SSMS window content which would save your time and effort.
You can verify the below path and get the files:
C:\Users\<>\Documents<>\SQL Server Management Studio\Backup Files
The above path may change depends on the windows version.
How does it happen?
There is a setting in Management Studio that allows the Autorecover option enabled by default. We can modify the default settings as per our need to reduce the risk of loss.
Go to SSMS -> Tools -> Options -> Environment -> AutoRecover
There are two different settings:
1) Save AutoRecover Information Every Minutes
This option will save the SQL Query window file at certain interval specified. You can set this value carefully on how frequent that you need to save your SSMS cahnges.
2) Keep AutoRecover Information for Days
This option will preserve the AutoRecovery information for specified days.
SSMS in SQL 2016 has come up with lots of new features. One of the features is enhanced scrollbar in SSMS. I personally believe the new enhancement in scrollbars will definitely help developers to work with SSMS with ease.
Let us look at the below picture to have an insight:
They are different color bocks on the right side of SSMS query window that shows the changes:
a. Green blocks show the saved lines of Query part in a window to disk
b. Yellow blocks show the query lines of unsaved/changed lines since last save to disk
c. Red blocks show any syntax errors in a query window
d. Blue block shows the current cursor location
It is definitely good to know to developers who plays around with SSMS very frequently.
“Cycle Clipboard” or “CTRL + SHIFT + V” is a short cut operation for pasting the items in the clipboard. This feature can paste last 20 items in the clipboard memory.
This is a very efficient method for developers to paste items not only the last copied, also any of the last 20 items. We need to just iterate through the clipboard memory by pressing CTRL+SHIFT+V until we get the desired item to be pasted.
Hope you enjoyed this tip, will reach you with more soon.
Today, I am going to introduce some of tools available for SQL Server formatting.
The list is not in order of any preferences, but just the way it is. Explore and use as your choice.
1. Format SQL – https://format-sql.com/
2. Instant SQL Formatter – http://www.dpriver.com/pp/sqlformat.htm
3. SQL Prompt from redgate – http://www.red-gate.com/products/sql-development/sql-prompt/
4. SQLinForm – http://www.sqlinform.com/
5. SQL Formatter – http://www.sql-format.com/
6. SQL beautifier – https://sourceforge.net/projects/fsqlf/
You may comment if you are using any other tools of your choice.
If you are a DBA and deal with lots of servers, especially, production servers, you need to be very careful on applying code changes or configurational changes. Any execution by mistake may lead you trouble, infact a very BIG trouble.
Here is a small TIP, you can follow while you connect to server – a color code method.
Step 1: While you connect the Server, select option .
Step 2: Go to Connection Properties and “Use custome color”.( I use RED for Production Servers, it is a personal choice anyway)
Once you connected with this option enabled, then whenever you connect to the server it uses RED color as the background for status bar.
This tip was very useful for me for a long time, hope you will also enjoy…