Before the comma
SELECT [Column1]
,[Column2]
,[Column3]
,[Column4]
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],
[Column2],
[Column3],
[Column4]
FROM [Table1]
Anybody got any idea why they chose this strange format?
7 Comments:
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
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
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
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
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
where
a = b
or
c = d
and
a > b
so much easier to comment out bits of code whilst debugging the query
10:05 PM
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
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
<< Home