views:

141

answers:

3

Is there some kind of plug in you can get for Microsoft SQL management studio that will:
1) help you format your sql (configuration, so we can get it to match our codeing guidelines)
2) highlight syntax that does not match our coding guidelines

For example if a tool could format the sql so that all selects look like:

SELECT
    tbl1.[ColumnX]
    tbl2.[ColumnY]
FROM
    tbl1 
JOIN
    tbl2 ON tbl1.[tbl2ID] = tbl2.[ID]
WHERE
    tbl2.[ColumnZ] = 'XYZ'

Also if the tool could highlight situations were there are ON ERROR statements and suggest we use TRY CATCH for example.

Hopefully there are plugins that integrate right into the management studio.

+2  A: 

Have you looked at SQL Prompt Pro from Red Gate ? It has layout functionality allowing you to layout your SQL to a shared style.

http://www.red-gate.com/products/SQL_Prompt/index.htm

Ben Hall
A: 

You might want to check out Toad SQL Server beta

Andy

A: 

SSMS Tools is free and has a code layout feature.

I don't know of any static code analyzers for SQL Server. I tend just to search the code:

SELECT * FROM sys.sql_modules WHERE definition NOT LIKE '%BEGIN CATCH%'
gbn