SQL Server Central is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
Search:  
 
 

How to lay out SQL Code

By Tony Davis, 2008/03/03

Total article views: 68 | Views in the last 30 days: 17

Anyone who inherits a database application dreads poorly laid-out SQL code. Development teams loathe it. Putting it right would be easier, if there was a common, agreed, standard in place, so why the difficulty?

In my years as a technical book editor, my life was ruled by Strunk&White, and various other tomes on writing style and grammar. I understand more than most the importance of applying clear and consistent style to the written word, and yet I was a keen defender of the author's, often highly non-standard, "voice"; when the rules get too rigid it's all too easy to sap the life and personality out of a piece of writing

It seems that the same streak of individualism persists with the styling of SQL code. Every point – from use lowercase vs. camelCase vs. PascalCase, to naming standards, to the number of tabs (tabs? No way! Spaces!) to indent – is argued and debated, and everyone has their own set of preferences. Red Gate's SQL Refactor product offers over 40 different options for laying out SQL code and yet the feedback the developers get is that this just isn't enough!

Individual style is all well and good when it comes to SQL laying out code, but this isn't necessarily aligned with the goal of making the design and intent of your code as readily apparent as possible to other members of your team. Also, as any regular users of the SQLServerCentral forums will attest, you are much likely to make yourself understood, and therefore be helped, if the code you present on the forums is readable.

In my recent blog on simple-Talk, I suggested that, overall, it might help if the standard were tightened up a bit. I'd be interested to hear what Database Weekly readers think about this. Is it important that we arrive at some sort of layout standard, or doesn't it really matter as long as a developer keeps it simple and consistent? If you think a little more "uniformity" would help, what elements would you like to see in this new standard?

A $50 Amazon voucher goes to the best contribution, as judged partially, and in a non-standard fashion, by me.

Thanks to all who contributed to my "Jérôme Kerviel" editorial on 2nd Feb. The winner of the $50 Amazon voucher on that occasion was Matt Miller!

Cheers,

Tony Davis.

Guest Editor

By Tony Davis, 2008/03/03

Total article views: 68 | Views in the last 30 days: 17
Your response
 
 
Related tags

Editorial    
 
Related content

Not Just At Home

By Steve Jones | Category: Editorial
| 360 reads

Dog Food

By Steve Jones | Category: Editorial
(not yet rated) | 262 reads

Halo 3

By Steve Jones | Category: Editorial
(not yet rated) | 252 reads
Already registered?  

Free registration required

To read the rest of this article, and access thousands of other articles, we ask you to register on the site and subscribe to our newsletters.

Register

E-mail address:
Password:
Password (confirm):

  

Subscriptions

We ask you to register on the site and subscribe to our newsletters. Subscribing to our newsletters gets you:

  • ALL of our content (thousands of articles, scripts, and forum postings)
  • A daily newsletter (example)
  • A weekly news round up (example)
  • The opportunity to ask and answer questions in our forums
  • A daily Question of the Day to test and help you increase your knowledge of SQL Server.

We ask that you give the newsletter a try for a week. Over 200,000 SQL Server Professionals a day find it entertaining and useful. If not, you are welcome to unsubscribe at anytime.

Steve Jones
Editor, SQLServerCentral.com