The journal of Paul M. Watson.

Wednesday, January 18, 2006

Before the comma

SELECT [Column1]
FROM [Table1]

I am not a fan of the way Microsoft SQL Server Management Studio for SQL2005 generates scripts. Look at how they put the comma on the next line rather than at the end of the preceding line. Everytime I generate a script I change it to:

SELECT [Column1],
FROM [Table1]

Anybody got any idea why they chose this strange format?


Anonymous Steve Crane said...

I think it's just a visual reminder that makes it less likely to forget to add a comma when appending or inserting to the column list.

5:15 PM

Blogger Paul Watson said...

Possibly but after awhile I will become blind to commas preceding the value just as I am now blind to commas after the value.

5:26 PM

Anonymous Colin D. Devroe said...

It has more to do with the preference of the man or woman that built that specific function in SQL... I seriously doubt there are any good studies that show someone would be more likely to leave a trailing comma than a preceding one. But I've been wrong before.

5:56 PM

Blogger Paul Watson said...

That is the likely explanation Colin but I'd hope the SQL team came to that coding style after some thought rather than just one coders preference.

Anybody know if I can change the templates in Management Studio?

6:10 PM

Anonymous Michael Butler said...

I use the comma at the beginning of a line method too.

a) because it makes it easy to comment out bits of code without having to alter the line above to remove the trailing comma

for the similiar reasons my where clauses look like

a = b
c = d
a > b

so much easier to comment out bits of code whilst debugging the query

10:05 PM

Anonymous Octavo said...

Meh, it should be quite clear why this was done this way:

To screw with your mind. You will now spend at least 30 mins and one blog post wondering about why MS did this. Other people will attempt to justify it. In the end MS has achieved their sinister goals - massive producivity loss... :p

11:24 AM

Blogger cleek said...

a leading comma makes it clear that the line is a continuation of the one above it.

it's still ugly and wrong.

9:49 PM


Post a Comment

Links to this post:

Create a Link

<< Home