Just curious, what are your SQL pet peeves ?

  • Everyone has their own style of writing code and doing things, but there are some pet peeves I've developed over the years, especially when I review other people's code, and I'm curious to know what pet peeves you guys have too.

    Here are some of mine:

    - Commas at the beginning of the line instead of end. Not sure why this bugs me, but it does.

    - Sub-Selects when a CTE or Join will work

    - SSIS packages with a single Script Task and nothing else. My thought, just write it in VS, save it to an EXE, and schedule it as a Windows Task instead of adding the overhead of SSIS and SQL

    - Spaces in column names. I generally try to use square brackets around my column names anyway, but I also always avoid using spaces in column names though not everyone else does

    - Requests to add a Total to the end of the query. Yes, I had this request just last week. This should be in whatever presents the data and not in the SQL query pulling the data.

    - Trying to use object oriented programming techniques within SQL. This comes from queries a few of my former colleagues (all Dot Net developers) used to write where they'd embed small queries into Views and Functions with their queries becoming a hierarchy of sorts. When troubleshooting I'd often have to dig 8-10 views or functions deep or more before finding where the table was actually used. A house of cards indeed.

    Anyway, not to sound like a stickler, but just a few things that always catch my eye 🙂 I assume most DBA's have a similar list of things that make them cringe, so just curious to see what's on anyone else's list.

  • Completely agree with you on the nested views/stored procedures.

    Trying to trouble shoot an issue when a stored procedure has called ten other procedures, which in turn call another load of procedures can be a real nightmare!

  • Let's see...in no particular order.

    storing datetime in ANY other datatype.

    NOLOCK

    Poor formatting

    Not having a space between parameters in a function call (parm1,parm2,parm3)

    Not having a space in a where clause or join condition. (MyColumn=SomeOtherColumn)

    GUIDs as clustered indexes

    _______________________________________________________________

    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/

  • Nolock

    Nested views

    Scalar UDFs

    Queries that try to handle too many possible cases

    Developers who think they know more than I do. 😉 :hehe:

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • In addition to what has been said (e.g. nolock, nesting views and procs, poor formatting etc)

    I don't like it when stored procedures are called "sprocs"

    I don't like calling a server by some nickname (e.g. prod2 when the box name is prod4) - talk about confusion there.

    Here's one more - Devs with SA access when the DBA doesn't

    Jason...AKA CirqueDeSQLeil
    _______________________________________________
    I have given a name to my pain...MCM SQL Server, MVP
    SQL RNNR
    Posting Performance Based Questions - Gail Shaw[/url]
    Learn Extended Events

  • GilaMonster (5/29/2014)


    Developers who think they know more than I do. 😉 :hehe:

    Ouch..... good thing that my title is no longer a "developer" :-P:-P

  • SQLRNNR (5/29/2014)


    Here's one more - Devs with SA access

    Fixed that for you.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • GilaMonster (5/29/2014)


    SQLRNNR (5/29/2014)


    Here's one more - Devs with SA access

    Fixed that for you.

    That in and of itself is a pet peeve. But it is far worse when a DBA doesn't even have that level of access.

    Jason...AKA CirqueDeSQLeil
    _______________________________________________
    I have given a name to my pain...MCM SQL Server, MVP
    SQL RNNR
    Posting Performance Based Questions - Gail Shaw[/url]
    Learn Extended Events

  • Wow, I agree with literally 100% of what you guys have entered, including 'sprocs'. We have a few non-DBA's who use this verbiage, and it always makes me cringe.

  • samalex (5/29/2014)


    Wow, I agree with literally 100% of what you guys have entered, including 'sprocs'. We have a few non-DBA's who use this verbiage, and it always makes me cringe.

    I don't know why but I always think of Vulcans when I hear "sproc".

    _______________________________________________________________

    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/

  • Sean Lange (5/29/2014)


    samalex (5/29/2014)


    Wow, I agree with literally 100% of what you guys have entered, including 'sprocs'. We have a few non-DBA's who use this verbiage, and it always makes me cringe.

    I don't know why but I always think of Vulcans when I hear "sproc".

    I think of Spacely Space Sprockets

    Jason...AKA CirqueDeSQLeil
    _______________________________________________
    I have given a name to my pain...MCM SQL Server, MVP
    SQL RNNR
    Posting Performance Based Questions - Gail Shaw[/url]
    Learn Extended Events

  • Sean Lange (5/29/2014)


    samalex (5/29/2014)


    Wow, I agree with literally 100% of what you guys have entered, including 'sprocs'. We have a few non-DBA's who use this verbiage, and it always makes me cringe.

    I don't know why but I always think of Vulcans when I hear "sproc".

    That, and I ignore the pun, would be my pointy ears:-D

  • samalex (5/29/2014)


    Everyone has their own style of writing code and doing things, but there are some pet peeves I've developed over the years, especially when I review other people's code, and I'm curious to know what pet peeves you guys have too.

    Here are some of mine:

    Just a quick thought:

    - Commas at the beginning of the line instead of end. Not sure why this bugs me, but it does.

    Columnar editing with variable length lines! Makes it easier, and of course ignoring JC's rant about punch cards.

    - Sub-Selects when a CTE or Join will work

    Working from bottom up, CTEs may not be the most readable options

    - SSIS packages with a single Script Task and nothing else. My thought, just write it in VS, save it to an EXE, and schedule it as a Windows Task instead of adding the overhead of SSIS and SQL

    Gives an immense power, packets creating packets, fully metadata driven, do it all the time.

    - Spaces in column names. I generally try to use square brackets around my column names anyway, but I also always avoid using spaces in column names though not everyone else does

    +100!

    - Trying to use object oriented programming techniques within SQL. This comes from queries a few of my former colleagues (all Dot Net developers) used to write where they'd embed small queries into Views and Functions with their queries becoming a hierarchy of sorts. When troubleshooting I'd often have to dig 8-10 views or functions deep or more before finding where the table was actually used. A house of cards indeed.

    +1, cannot object to that!

    Anyway, not to sound like a stickler, but just a few things that always catch my eye 🙂 I assume most DBA's have a similar list of things that make them cringe, so just curious to see what's on anyone else's list.

    Not being a DBA, no comment:w00t:

  • I'm not in favor of "sprocs" but I prefer them over "store procedures". AFAIK, we're not selling anything.

    At work we have DTS that simply call an SP or even better, they have a SQL task with "SELECT 1".

    But one of the worst things is having to read code written as if formatting was prohibited and the less lines the better.

    Other things are:

    SQL-86 Joins and JOIN keywords on the right of the tables.

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • Luis Cazares (5/29/2014)

    JOIN keywords on the right of the tables.

    +1000 That one drives me nuts!!! (ok I know it is a short trip)

    _______________________________________________________________

    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/

Viewing 15 posts - 1 through 15 (of 272 total)

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