SQL classics: #1
Aug. 6th, 2012 09:45 pmI do a lot of troubleshooting/refactoring of database queries. By themselves they don't amount to much of anything, but when they all start working together small inefficiencies turn into large inefficiencies. I've resisted sharing some of my favorite things because they're pure geek and very few people will find the humor in them. But tonight I can't resist because I found one that is just too good bad to be true.
From a real SQL stored procedure, I couldn't make this stuff up, table names changed to protect the guilty:
Set @SCENCode = (Select Code From the.table Where Num =@Scenint)
Set @Scen =(Select num From the.table Where Code =@SCENCode)
Obfustication: 1
Inefficiency: 2
Utter Uselessness: 5
From a real SQL stored procedure, I couldn't make this stuff up, table names changed to protect the guilty:
Set @SCENCode = (Select Code From the.table Where Num =@Scenint)
Set @Scen =(Select num From the.table Where Code =@SCENCode)
Obfustication: 1
Inefficiency: 2
Utter Uselessness: 5