4

Folks, is there a tool to format/indent SQL Server queries in query window ?

SoftwareGeek
  • 15,234
  • 19
  • 61
  • 78

4 Answers4

8

With Apex SQL Refactor, you can specify your formatting preferences and reformat selected code or the entire window at any time using a keyboard shortcut. There's a free version.

ApexSQL Refactor

srmark
  • 7,942
  • 13
  • 63
  • 74
6

+1 to JackM.

Just add a mention for some other (not free) tools available from Red Gate, depending on exact requirements.

SQL Prompt
SQL Refactor

Might be something you'd be interested in.

AdaTheDev
  • 142,592
  • 28
  • 206
  • 200
2

Format code in SQL Management Studio

Jack Marchetti
  • 15,536
  • 14
  • 81
  • 117
2

Older question which has much more activity and more answers: SQL Formatter for SQL Management Studio

My contributon to this mess is Poor Man's T-SQL Formatter / http://poorsql.com - free, open-source, does bulk formatting from command-line, SSMS plugin, etc, and (in theory) handles all SQL syntax up to SQL Server 2008 (R2).

Community
  • 1
  • 1
Tao
  • 13,457
  • 7
  • 65
  • 76