Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Format SQL statements in SQL Server Management Studio 2008

I am trying to use Ctrl K + Ctrl D (format document) in SQL Server Management Studio. It gives the message

The key combination (key, key) is bound to command(command) which is not currently available.

I also tried Ctrl A + Ctrl K + Ctrl F, and that didn't work either.

Is there any update or fix that I need to install for that?

like image 313
user979189 Avatar asked Dec 20 '11 21:12

user979189


People also ask

How do I format a query in SQL Server Management Studio?

Format SQL Code in SSMS Query Window To use the SSMS add-in component we will have to close and then open SSMS after the install of the add-in. Then open a SSMS query window, highlight the code that needs to be formatted. Then select Format T-SQL Code from the SSMS Tools menu. Here is the code after the formatting.

Does SSMS have a SQL Formatter?

Format SQL code using SSMS optionsSSMS provides a couple of options to format SQL code. Those options are indenting, tab sizing, make all code in upper or lower case, comment/uncomment selected code, etc.

How do I format a SQL statement?

Select Edit -> SQL Formatter -> Format Selected Query (or press Ctrl+F12). -- Format All Queries: To format the whole batch of queries entered in the SQL window. Select Format -> SQL Formatter -> Format All Queries (or press Shift+F12).


2 Answers

There is nothing to fix - SQL Server Management Studio is not Visual Studio and does not contain a SQL pretty printer.

In other words, SSMS does not have a document formatting option out of the box.

See the answers to SQL Formatter for SQL Management Studio for options.

like image 83
Oded Avatar answered Sep 21 '22 11:09

Oded


I was struggling with this, Finally found this Ctrl +K, Ctrl+Y and it worked for me. But you need to have SQL Prompt.

like image 42
Kunal Prajapati Avatar answered Sep 19 '22 11:09

Kunal Prajapati