SQL SERVER – SQL Code Formatting Tools

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 and I found two of the tools worth mentioning here.

Title card: SQL Server Code Formatting Tools on a dark gray background


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

Both are good tools and still today after many years I use them. If you have come across any other such a great tool, please feel free to add to this blog post.

Published by Pinal Dave on SQLAuthority. More of my work at pinaldave.com.

File format, SQL Scripts, SQL Server, SQL Utility
Previous Post
SQL SERVER – Script/Function to Find Last Day of Month
Next Post
SQL SERVER – 2005 Comparison EXCEPT operator vs. NOT IN

Related Posts

3 Comments. Leave new

Leave a Reply

Your email address will not be published. Required fields are marked *

Fill out this field
Fill out this field
Please enter a valid email address.