Launch week: the Season Pass & Fundamentals Week are 50% off — ends in 6d 03h 31mSee the sale

News & Opinion

I’m just saying it’s valid T-SQL syntax, that’s all.

Bad idea #1
Bad idea #2
Bad idea #3

Free, 3× a week

Get my new posts by email

Three posts a week, plus a Monday roundup of the best database news from around the web.

44 comments

  1. And that is why I have my 2AM rule: Write your code so that I can debug it when it breaks (inevitably) in the middle of the night.

  2. I just remember a situation in the past

    1-Select * from sometable where somefield IS NULL => Empty Result
    2-Select * From sometable => Show somefield as null

    I took some time to realize that shown NULL are in fact a text content of ‘NULL’

  3. CREATE DATABASE #
    GO
    USE #
    GO
    CREATE SCHEMA #
    GO
    CREATE TABLE #.#(# VARCHAR(50))
    GO
    INSERT INTO #.#(#)
    VALUES (‘#’)
    GO
    CREATE TABLE ###
    (
    # VARCHAR(50)
    )
    GO
    INSERT INTO ###(#)
    VALUES (‘#’)
    GO
    SELECT #.#, ##.# FROM #.#.# #
    CROSS JOIN ### ##

  4. Or perhaps an inner join

    CREATE DATABASE #
    GO
    USE #
    GO
    CREATE SCHEMA #
    GO
    CREATE TABLE #.#(# VARCHAR(50))
    GO
    INSERT INTO #.#(#)
    VALUES (‘#’)
    GO
    CREATE TABLE ###
    (
    # VARCHAR(50)
    )
    GO
    INSERT INTO ###(#)
    VALUES (‘#’)
    GO
    SELECT #.#, ##.# FROM #.#.# #
    INNER JOIN ### ##
    ON #.# = ##.#

  5. –===============
    — Bad Idea #5 —
    –===============
    CREATE DATABASE [[];
    GO
    USE [[];
    GO
    CREATE SCHEMA [[];
    GO
    CREATE TABLE [[].[[]([[] VARCHAR(50));
    GO
    SELECT [[].[[] FROM [[].[[].[[] [[]
    GO

    –===============
    — Bad Idea #6 —
    –===============
    CREATE DATABASE “[]”;
    GO
    USE “[]”;
    GO
    CREATE SCHEMA “[]”;
    GO
    CREATE TABLE “[]”.”[]”(“[]” VARCHAR(50));
    GO
    SELECT “[]”.”[]” FROM “[]”.”[]”.”[]” “[]”
    GO

    1. Using [[] or [[[[]] for the names and keeping the brackets for quoting makes the final select so much sexier:
      SELECT [[[]]],[[[[[]]]]] FROM [[[]]].[[[]]].[[[]]]

  6. –============================
    — This could go on forever —
    –============================
    CREATE DATABASE [?];
    GO
    USE [?];
    GO
    CREATE SCHEMA [?];
    GO
    CREATE TABLE [?].[?]([?] VARCHAR(50));
    GO
    SELECT [?].[?] FROM [?].[?].[?] [?]
    GO

  7. CREATE DATABASE “”””;
    GO
    USE “”””;
    GO
    CREATE SCHEMA “”””;
    GO
    CREATE TABLE “”””.””””(“””” VARCHAR(50));
    GO
    INSERT INTO “”””.””””(“”””)
    VALUES (‘”‘)
    GO
    SELECT “”””.”””” FROM “”””.””””.”””” “”””
    GO

  8. Brilliant! I must be a geek to find this so funny.
    You missed an opporchancity to include yet another NOLOCK, thus:
    SELECT NOLOCK NOLOCK FROM NOLOCK.NOLOCK.NOLOCK NOLOCK WITH (HOLDLOCK);
    Alias the NOLOCK column as, well…NOLOCK. Also, I think it makes more sense to run in serializable isolation 🙂

  9. Well if I’m being honest, it’s not that much worse than the BAJILLIONS of uses that NOLOCK has been put to in the production databases around here.

  10. Slightly related but just as maddening, a developer over here named a table IDDef_Log. Every time you try to type “ID”(which is basically all the time), intellisense jumps in if you’re not paying close attention and renames “ID” to “IDDef_log” and then you gotta go back and delete the extra characters . We basically curse him all day long!!

    1. BD, if you haven’t seen it and don’t mind the profanity, this answer to the StackOverflow question “What is the best comment in source code you’ve ever encountered” should hit home: http://stackoverflow.com/a/184673/13495. I’m not inferring that the IDDef_Log creator was named Richard, but it sounds like you have lived in a place near this guy’s world.

Leave a comment

Your email address will not be published. Required fields are marked *

Email me about new comments: