Two t-SQL gems



  • Two procedures I found in one of the production databases that I am maintaining

    ALTER PROCEDURE [dbo].[sp_testTempDB]
    AS 
        CREATE TABLE #testtempdb ( test INT PRIMARY KEY )
        INSERT  INTO #testtempdb VALUES  ( 1 )
    
    ALTER PROCEDURE [dbo].[sp_Now]
        @myDate datetime output
    AS 
        select  @myDate = getdate()
    


  •  Ah, unbridled retardation!



  • This looks like code I might not ever want to call.



  • @coentje said:

    ALTER PROCEDURE [dbo].[sp_testTempDB]
    AS
    CREATE TABLE #testtempdb ( test INT PRIMARY KEY )
    INSERT INTO #testtempdb VALUES ( 1 )

    ALTER PROCEDURE [dbo].[sp_Now]
        @myDate datetime output
    AS 
        select  @myDate = getdate()
    

     

     Not the best to be on a production db, but not much of a wtf either. I've created tons of sp like that when I can't remember the minutia of the wording of some sql thing.  I tend to drop the procedures when I'm done, though, so they don't get promoted.

    The first was the developer wondering "When do procedures clean up their # temp tables?".  He created the procedure, then called it a couple times. Probably like:

    [code]

    exec  sp_testTempDB
    exec  sp_testTempDB
    BEGIN TRANSACTION
    exec  sp_testTempDB
    exec  sp_testTempDB
    ROLLBACK TRANSACTION

    [/code]

    The second one was obviously an attempt to get another threesome with Morb's mom and aunt.



  •  Second one doesn't seem that WTF.  I imagine the code came from a shop that paid lip service to PCI compliance or one of the other dreaded 3~5 letter standsards/laws. Probably a programming policy that all datestamps come from the database for 100% interoperability.



  • @Hasteur said:

    I imagine the code came from a shop that paid lip service to PCI compliance or one of the other dreaded 3~5 letter standsards/laws.
    I can't even remotely fathom how PCI/DSS would come into play for something that is essentially an alias to a built-in function.



  • @Lingerance said:

    @Hasteur said:
    I imagine the code came from a shop that paid lip service to PCI compliance or one of the other dreaded 3~5 letter standsards/laws.
    I can't even remotely fathom how PCI/DSS would come into play for something that is essentially an alias to a built-in function.
     

    Manager: "We need all system dates to come from a single source. DateTime.Now is out. We'll use the database, since it generates our timestamps anyways."

    Grizzled Vetran: "I won't have any inline SQL in my system. Not even 'SELECT getdate()'."

    DBA/Air Displacer: "I'll write a stored procedure. None of the devs will need to know SQL, and it's more secure, and it's faster!"

    coentje: {blackberry out, forums.thedailywtf.com open...}



  • @Lorne Kates said:

    @Lingerance said:

    @Hasteur said:
    I imagine the code came from a shop that paid lip service to PCI compliance or one of the other dreaded 3~5 letter standsards/laws.
    I can't even remotely fathom how PCI/DSS would come into play for something that is essentially an alias to a built-in function.
     

    [b]Manager[/b]: "We need all system dates to come from a single source. DateTime.Now is out. We'll use the database, since it generates our timestamps anyways."

    [b]Grizzled Vetran[/b]: "I won't have any inline SQL in my system. Not even 'SELECT getdate()'."

    [b]DBA/Air Displacer[/b]: "I'll write a stored procedure. None of the devs will need to know SQL, and it's more secure, and it's faster!"

    coentje: {blackberry out, forums.thedailywtf.com open...}

     

    Which are you?



  • @SQLDave said:

    Which are you?
     

    I'm the Wooden Table salesman in a meeting with the CFO, espousing the ROI-potential of our lacquered model over the "Staples special". It's coated for speed and security. And those other ones? They'll rot faster than bits stored in Linux. (Why do you think they call it Open Sores? hahahahaha, braugh).


Log in to reply
 

Looks like your connection to What the Daily WTF? was lost, please wait while we try to reconnect.