Follow sqlserver-dba.com

Subscribe to RSS feed  Follow @jackvamvas - Twitter

*Use the Comments section for questions

SQLServer-DBA.com Links

Dba_db2_button

dba-ninja.com

SQL Server DBA Jobs

Bad indentation in stored procedures

25 December,2014 by Tom Collins

Bad indentation in a stored procedure is inefficient. I receive daily requests to analyse sql queries for performance issues , but quite often I spend the first part of the job applying indentation to make the code easier to read.

I don’t think bad indentation as bad coding and it doesn’t make the code run inefficiently. But it does make troubleshooting a slow running query  more difficult. In an earlier post - Stored Procedure Checklist - I highlight a checklist of items which have positive performance impact on the query.

MAKE SQL QUERIES EASIER TO TROUBLESHOOT

When I start analysing the stored procedure , particularly the very long stored procedures, I try to understanding the flow of the code. Quite often other developers have added to the original code – which adds to different styles.

As well as helping others to read the code , it also allows the developer to read their own code , when required to revisit the original code.

Along with good indentation another useful habit is to use Commenting. I prefer a comment block at the top with usage and revision history . Snippets throughout the code to enhance the understanding

As it’s the holiday season , maybe you could consider adding it to your New Year’s resolution list.

Read More on Stored Procedure management

SQL Server - Stored Procedures versus ad-hoc paramaterized queries.Which is faster?

Last time a stored procedure was executed - SQL Server DBA

Grant execute on all stored procedures - SQL Server DBA

 

 


Author: Tom Collins (http://www.sqlserver-dba.com)


Share:

Verify your Comment

Previewing your Comment

This is only a preview. Your comment has not yet been posted.

Working...
Your comment could not be posted. Error type:
Your comment has been posted. Post another comment

The letters and numbers you entered did not match the image. Please try again.

As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.

Having trouble reading this image? View an alternate.

Working...

Post a comment on Bad indentation in stored procedures


sqlserver-dba.com | SQL Server Performance Tuning | SQL Server DBA:Everything | FAQ | Contact|Copyright & Disclaimer