>>>Our company is in the process of implementing documentation processes in the programming department. In discussions, it was determined that none of the programmers were aware of a way to place comments in an SQL query in order to document what the SQL code was doing at a glance.
>>>
>>>Can anyone here provide any input?
>>>
>>>Thanks, Mike
>>
>>Not sure, if this is the answer you're looking for, but do you know, what you can:
>>
>>select myField1, myField2, ;
>> from table1 inner join table2 ;
>>
>>
>>e.g. put your comments inside the select statement?
>>
>>Be careful to not end comment line with ";" otherwise your next line would become a comment too...
>
>IMO, it's realy bad idea to comment query like that. It makes it hard to read and maintain.
I agree in general and rarely use it. Only in cases when I don't need some fields anymore or I modified some portion of query, I put part, which is no longer used in comments.
However, Michael asked a reasonable question: how can we comment our queries? I didn't do it in my code, but it's not always obvious for another programer, what's the purpose of the query and why it's written this particular way...
Can you suggest some good commenting style?
Thanks in advance.
If it's not broken, fix it until it is.
My Blog