Bad Practices/Worse Practices

  • I recently sarcastically wrote a proc:

    create proc dbo.UniversalMagic

    (@SQL_in varchar(max))

    as

    begin try

    exec (@sql_in)

    end try

    begin catch

    exec dbo.universalmagic @sql_in

    end catch

    This made me think a moment.

    There are "bad practices" in SQL, like having twenty indexes on a five-column table in an OLTP database.

    There are what could probably be called "worse practices", like having all access to a production database be through the sa login (with a decent password but every employee knows it), or cursors that call cursors iteratively.

    There are even what might be called "worst practices", like having a critical production database on a 10-disk RAID 0 array and never running backups, or having the sa password be blank.

    I think, however, that there should be a category for actively destructive code. Like the above proc, or like throwing everything into a single table defined with an ID and a varchar(max) column, or having sa with a blank password and having xp_cmdshell active. I'm nominating "appocalyptic practices". Any thoughts?

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

  • Heh... right there with ya, Gus... seems like the long way to spell "Death by SQL", though 😀

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • Is a DBA there? If not, anyone is a "DBA" then.

  • I'd have to go all the way to "stupid practices." If I was feeling kind, I might call it "ignorant practices." If I wasn't feeling kind, it'd be "f'ing stupid practices."

    But then, I make people angry, so my take might be off.

    "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

  • I'm wondering if you could wrap that in a recursive CTE with OPTION (MAXRECURSION 0)? Hmm, and then just rename it CTEHardWareKiller and sit back an pick up the old fiddle while Rome burns....:)

    ----------------------------------------------------------------------------------
    Your lack of planning does not constitute an emergency on my part...unless you're my manager...or a director and above...or a really loud-spoken end-user..All right - what was my emergency again?

  • This could also be called job security.

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply