SQL Code Formatting is very important. Every SQL Server DBA has its own preference about formatting. I like to format all keywords to uppercase. Following are two online tools, which formats SQL Code very good. I tested following script with those tools.
use tempdb go create procedure SP_NonFatal_INSERT @Column2 int =NULL AS declare @ErrorMsgID int insert NonFatal values (@Column2) set @ErrorMsgID =@@ERROR if @ErrorMsgID 0 BEGIN RAISerror (‘An error occured updating the NonFatal table’,10,1) end GO
Tool 1 : Instant SQL Formatter
USE TEMPDB
GO
CREATE PROCEDURE sp_NONFATAL_INSERT
@Column2 INT = NULL
AS
DECLARE @ErrorMsgID INT
INSERT NONFATAL
VALUES(@Column2)
SET @ErrorMsgID =@@ ERROR
IF @ErrorMsgID 0
BEGIN
RAISERROR (‘An error occured updating the NonFatal table’,10,1)
END
Tool 2 : SQLinForm
USE tempdb GO
CREATE PROCEDURE
sp_NonFatal_INSERT @Column2 INT =NULL
AS
DECLARE
@ErrorMsgID INT
INSERT NonFatal VALUES (@Column2) SET @ErrorMsgID =@@ERROR
IF @ErrorMsgID 0
BEGIN
RAISERROR ('An error occured updating the NonFatal table',10,1)
END
Reference : Pinal Dave (http://blog.SQLAuthority.com)












[...] Pinalkumar Dave writes about two SQL formatting tools. [...]
[...] SQL SERVER – SQL Code Formatter Tools [...]
You can also try Devart’s SQL Formatter Tool – SQL Complete. In SQL Complete 4 its formatting features are much better!
You can read about it and download the free trial version here:
http://www.devart.com/dbforge/sql/sqlcomplete/
Hey Pinal I’d like to share a PowerShell based formatter (offline) http://blogs.msdn.com/b/arvindsh/archive/2013/02/28/t-sql-formatter-a-powershell-script.aspx which can be useful for command line batch mode formatting.