When When Situation

I have been pondering best and worst SQL practices lately. When I was a younger man, I had a mentor tell me one time, specifically about a COBOL program he was writing, “As long as it works and works quickly…who gives a rat’s ass?” I have kept that with me, but have not always adhered to the logic because like others I eschew common bad practices in SQL. DBA’s know, but of course do not always obey the guidelines of others who have come to believe that there are certain things that should never be done. Here is a quick list of wrist slaps.


Temp Tables….slap….WHY NOT…ouch

dynamic SQL…(Set @whynot = ‘select horrifying_SQL_injection_attack from #mytable where @InputInjectionHere = SemiColon; Exec @whynot)

xp_cmdshell  (NEVER)

We know what not to do and we develop skills to thwart these evil thoughts when temptation sets in. 

So..should I spend the rest of my working life avoiding bad practices when at times they are the quickest and easisest solutions–one-off answers to questions that DBA’s get asked all the time? I guess the answer would be yes, avoid it because you are smart and know better. But temp tation…like temp  tables is difficult to avoid.

So over the next few blogs, I will jot down all of the bad, bad, bad things I do everyday. This will be my tell all, so others can gasp at my egregiousness. 

I feel shamed already.

Select Shame INTO #MyTemporaryShame where OverItAlready = “Yes”