June 5, 2019 at 9:00 am
This was removed by the editor as SPAM
June 5, 2019 at 10:03 am
In the Crystal Reports report interface, there used to be a small space at the bottom where you could expose the underlying HTML code. A comment at the bottom of the page said something to the effect of, “Internet Explorer needs to have this empty DIV tag here. I don’t know why, though.”<!--more-->
June 5, 2019 at 12:23 pm
Query said:
...WHERE 1=0...
Comment in front of the query said:
-- WHERE 1 = 0
No explanation for it at all.
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
June 5, 2019 at 12:28 pm
Query said: ...WHERE 1=0... Comment in front of the query said: -- WHERE 1 = 0 No explanation for it at all.
I hate "where 1=0" - I ..use "where @debugmode=1" and pass that in as a parameter.
the number of times one of my devs has hardcoded "where 1=2" and forgotten to take it out is annoying
MVDBA
June 5, 2019 at 1:12 pm
Another example of bad commenting in code are when the comments contain actual blocks of commented code with no explanation. Like, if someone tweaks a 100 line SELECT statement, there is really no reason to keep the original statement sitting between /* */ for the sake of posterity. All that's needed is a simple one line comment with the date, developer's name, and a brief explanation that the statement was modified for performance reasons. If the source is maintained in VCS, then it's easy to go back there and see revisions made to the code.
"Do not seek to follow in the footsteps of the wise. Instead, seek what they sought." - Matsuo Basho
June 5, 2019 at 1:29 pm
Reviewing legacy code few years back, I came across a view which was couple of hundred Kb in size (object definition's data size). Thinking that that one was something worth looking into, I scripted it and found few thousand lines of comments and code, all commented out and the last line was :
SELECT * FROM TABLE_NAME
😎
The more funny thing was that the name of the view was product related, the table was "person" type table, one couldn't make it up!
June 5, 2019 at 1:33 pm
In the Crystal Reports report interface, there used to be a small space at the bottom where you could expose the underlying HTML code. A comment at the bottom of the page said something to the effect of, “Internet Explorer needs to have this empty DIV tag here. I don’t know why, though.”<!--more-->
Haha I have been guilty of comments like that, especially when dealing with bizarre formatting nonsense with IE. There are times with IE that you just have to muck around until find something that is acceptable to its non-standard interpretation of HTML.
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
June 5, 2019 at 1:44 pm
Years ago I came across comments in the code that contained the logon credentials for the DB server. Sysadmin account too - of course. It was for a DEV system so nobody cared. I just shake my head when I see stuff like that.
June 5, 2019 at 1:47 pm
My two favourites were both from COBOL programs many years ago.
June 5, 2019 at 1:48 pm
I hate "where 1=0" - I ..use "where @debugmode=1" and pass that in as a parameter. the number of times one of my devs has hardcoded "where 1=2" and forgotten to take it out is annoying
WHERE 1 = 0 is not always a debugging construct.
Eg.
SELECT ... INTO #SomeTable WHERE 1 = 0
Creates an empty temp table with the desired structure (as defined in the SELECT).
The absence of evidence is not evidence of absence.
Martin Rees
You can lead a horse to water, but a pencil must be lead.
Stan Laurel
June 5, 2019 at 2:00 pm
MVDBA (Mike Vessey) wrote:I hate "where 1=0" - I ..use "where @debugmode=1" and pass that in as a parameter. the number of times one of my devs has hardcoded "where 1=2" and forgotten to take it out is annoying
WHERE 1 = 0 is not always a debugging construct. Eg. SELECT ... INTO #SomeTable WHERE 1 = 0 Creates an empty temp table with the desired structure (as defined in the SELECT).
have you ever tried to get an estimated execution plan for performance tuning with a "select into" in the proc? the optimiser just throws an error about invalid object #sometable
It's on our coding standards list as "annoys the DBA when he has to improve performance" 🙂
right above "forgetting to remove your debug code will exclude you from the free cakes the DBA makes for you"
all of our guys have the redgate tools, if you write a "Select * into", hover over it, then it will allow you to generate a CREATE #Table script and convert it into
create table #x
insert into x select * from ....
one of the most useful features of toolbelt i have used in the past week
MVDBA
June 5, 2019 at 2:08 pm
I think it is a ridiculous waste of time when someone comments on the obvious, like:
counter++; // increment counter
Really??
June 5, 2019 at 2:14 pm
...
all of our guys have the redgate tools, if you write a "Select * into", hover over it, then it will allow you to generate a CREATE #Table script and convert it into create table #x insert into x select * from .... one of the most useful features of toolbelt i have used in the past week
Is this in Prompt? I just tried with this query and it does not seem to do a complete job:
DROP TABLE IF EXISTS #SomeTable;
SELECT TableName = t.name
,SchemaName = SCHEMA_NAME(t.schema_id)
INTO #SomeTable
FROM sys.tables t
WHERE 1 = 0;
The absence of evidence is not evidence of absence.
Martin Rees
You can lead a horse to water, but a pencil must be lead.
Stan Laurel
June 5, 2019 at 2:38 pm
My formative years of programming I used an ASCII facepalm art as the header block.
I felt it gave a good indication of what anyone might expect if they proceeded further. Y'know, managing expectations...
Thankfully (sadly...) that system and all the code is now long gone.
I am guilty of venting sometimes in code. Particularly relating to poor decisions outside of my control that lead to certain coding choices.
And in hindsight gives some insight into why a particularly convoluted piece of code exists.
June 5, 2019 at 3:12 pm
I would take Where 1 = 0 any day over what I saw:
AND contactid is null
(several other conditions)
AND contactid is not null
(a couple more conditions)
Someone did that without a comment to disable a query. When we wanted to enable it again, after I finally found this code, I had to figure out which way was correct.
Viewing 15 posts - 136 through 150 (of 156 total)
You must be logged in to reply to this topic. Login to reply