qt8gt0bxhw|20009F4EEE83|RyanMain|subtext_Content|Text|0xfbffe20000000000e000000001000200
I just read a new post on the Daily WTF. Although this one does raise some question of it's validity of being from real live production code, I tend to belive it because I've come across my share of completely idiotic & inane code from time to time. This one takes the cake:
CREATE PROCEDURE sp_get_order (
@OrderID int
) AS
select * into #temp_order from Orders
delete from #temp_order where OrderID<>@OrderID
select * from #temp_order
drop table #temp_order
Wow. Enough to leave you speechless. But really, coming across this kind of code in a client's production system is what dreams are made of. You do a fix that takes all of 3.256805 seconds to make to change this to a select * from orders where orderid = @orderid and your client sees you as a God, and rightly so ;-) because you've increased performance of their app by 200% with just a few keystrokes. But really, the developer knew how to create a temp table with the orders data, delete everything where the id was not the id he wanted and then drop the temp table, but didn't know how to do a “where orderid = @orderid”? I find that very questionable, but I hate to say I've seen code every bit as ridiculous as that from time to time.