1

Are there any provision available in SSMS to align the SQL code. Arrange the SQL SP scripts in a readable format. Whenever I align the SP scripts and run a ALTER PROC. The scripts got misaligned when i retrieve the SP code using sp_helptext.

Like how we align the C# OR .aspx codes in Visual Studio using the shortcut key Ctrl +KD, Any option available in SSMS?

Tomas Pastircak
  • 2,867
  • 16
  • 28
Kihtrak J
  • 132
  • 1
  • 2
  • 7

3 Answers3

2

There's a bunch -- some free, some not. Google 'SQL Format SSMS'...

Chains
  • 12,541
  • 8
  • 45
  • 62
1

You can try SQL Prompt. However it is not free.

http://www.red-gate.com/products/sql-development/sql-prompt/

enter image description here

You might also want to look at this answer -

SQL Formatter for SQL Management Studio

Community
  • 1
  • 1
Win
  • 61,100
  • 13
  • 102
  • 181
0

There is auto-formatting function available in SSMS. Please refer book online topic on Manage Code Formatting.

user353gre3
  • 2,747
  • 4
  • 24
  • 27
  • When I try to enable it using the following steps, it resets back. I am not able to select option 'smart' To automatically indent all of your code On the Tools menu, click Options. Click Text Editor. Click All Languages. Click Tabs. Click Smart. – Kihtrak J Apr 24 '14 at 16:45
  • This is the basic free stuff that comes with SSMS. Even though the tools->options dialog box shows it as reset, the settings should still work. At least, that has been my experience. Your modified settings file is saved in the folder `%USERPROFILE%\Documents\SQL Server Management Studio\Settings`, and that is used to load your personalized settings. If you want to pay or your IT allows third party freebies, there are several out there. – user353gre3 Apr 24 '14 at 17:19