Are the posted questions getting worse?

  • Alvin Ramard (11/19/2015)


    Eirikur Eiriksson (11/19/2015)


    Alvin Ramard (11/19/2015)


    Eirikur Eiriksson (11/19/2015)


    Luis Cazares (11/19/2015)


    I feel excluded.

    How come?

    😎

    Luis, I'll include you with me. 🙂

    That looks way too close to a union all statement for comfort:-P

    😎

    Union all???? I didn't say I was including the rest of you! 😀

    That's why there is EXCEPT:-D

    😎

  • Luis Cazares (11/19/2015)


    Eirikur Eiriksson (11/19/2015)


    Luis Cazares (11/19/2015)


    I feel excluded.

    How come?

    😎

    You left my method out

    Couldn't fit it in the select statement, too many EXEC'y thingies in there, any alternatives?

    😎

  • Let's ask a question in a SQL Server 2012 forum when it is really about Access. Oh, and I even prefaced my answer with "..., and if you are using SQL Server 2012..." and try and use it in Access and then post back that it didn't work.

  • Lynn Pettis (11/19/2015)


    Let's ask a question in a SQL Server 2012 forum when it is really about Access. Oh, and I even prefaced my answer with "..., and if you are using SQL Server 2012..." and try and use it in Access and then post back that it didn't work.

    Did someone move the question? Looks like the Access forum to me. :ermm:



    Alvin Ramard
    Memphis PASS Chapter[/url]

    All my SSC forum answers come with a money back guarantee. If you didn't like the answer then I'll gladly refund what you paid for it.

    For best practices on asking questions, please read the following article: Forum Etiquette: How to post data/code on a forum to get the best help[/url]

  • Alvin Ramard (11/19/2015)


    Lynn Pettis (11/19/2015)


    Let's ask a question in a SQL Server 2012 forum when it is really about Access. Oh, and I even prefaced my answer with "..., and if you are using SQL Server 2012..." and try and use it in Access and then post back that it didn't work.

    Did someone move the question? Looks like the Access forum to me. :ermm:

    Probably, I did send a report asking that it be moved to an Access forum.

  • Cool, I just found a thread that reminds me on the Bankers Rounding Function threads.

    Nice that some one else is in the flame war with this particular adversary.

  • Eirikur Eiriksson (11/19/2015)


    So to recap, here are 9 different methods for getting the current time, any additions anyone?

    😎

    SELECT

    GETDATE()

    ,SYSDATETIME()

    ,SYSDATETIMEOFFSET()

    ,CURRENT_TIMESTAMP

    ,SYSUTCDATETIME()

    ,GETUTCDATE()

    ,DATEADD(MILLISECOND, (@@CPU_BUSY + @@IDLE) * SQRT(64.2548),(SELECT sqlserver_start_time FROM sys.dm_os_sys_info))

    ,(SELECT MAX(start_time) FROM sys.dm_exec_requests)

    ,(SELECT DATEADD(ms,ms_ticks%1000,DATEADD(ss,ms_ticks/1000,sqlserver_start_time)) FROM sys.dm_os_sys_info)

    There are many more but, just to wet the appetite for other possibilities...

    SELECT {fn NOW()};

    SELECT {fn CURRENT_DATE()} + ' ' + {fn CURRENT_TIME()};

    EXEC xp_CmdShell 'Date /T & Time /T';

    --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)

  • Jeff Moden (11/19/2015)


    Eirikur Eiriksson (11/19/2015)


    So to recap, here are 9 different methods for getting the current time, any additions anyone?

    😎

    SELECT

    GETDATE()

    ,SYSDATETIME()

    ,SYSDATETIMEOFFSET()

    ,CURRENT_TIMESTAMP

    ,SYSUTCDATETIME()

    ,GETUTCDATE()

    ,DATEADD(MILLISECOND, (@@CPU_BUSY + @@IDLE) * SQRT(64.2548),(SELECT sqlserver_start_time FROM sys.dm_os_sys_info))

    ,(SELECT MAX(start_time) FROM sys.dm_exec_requests)

    ,(SELECT DATEADD(ms,ms_ticks%1000,DATEADD(ss,ms_ticks/1000,sqlserver_start_time)) FROM sys.dm_os_sys_info)

    There are many more but, just to wet the appetite for other possibilities...

    SELECT {fn NOW()};

    SELECT {fn CURRENT_DATE()} + ' ' + {fn CURRENT_TIME()};

    EXEC xp_CmdShell 'Date /T & Time /T';

    That's our Jeff, bring on the ODBC conical functions. Those are so much fun when you see them for the first time.

  • Lynn Pettis (11/19/2015)


    Jeff Moden (11/19/2015)


    Eirikur Eiriksson (11/19/2015)


    So to recap, here are 9 different methods for getting the current time, any additions anyone?

    😎

    SELECT

    GETDATE()

    ,SYSDATETIME()

    ,SYSDATETIMEOFFSET()

    ,CURRENT_TIMESTAMP

    ,SYSUTCDATETIME()

    ,GETUTCDATE()

    ,DATEADD(MILLISECOND, (@@CPU_BUSY + @@IDLE) * SQRT(64.2548),(SELECT sqlserver_start_time FROM sys.dm_os_sys_info))

    ,(SELECT MAX(start_time) FROM sys.dm_exec_requests)

    ,(SELECT DATEADD(ms,ms_ticks%1000,DATEADD(ss,ms_ticks/1000,sqlserver_start_time)) FROM sys.dm_os_sys_info)

    There are many more but, just to wet the appetite for other possibilities...

    SELECT {fn NOW()};

    SELECT {fn CURRENT_DATE()} + ' ' + {fn CURRENT_TIME()};

    EXEC xp_CmdShell 'Date /T & Time /T';

    That's our Jeff, bring on the ODNC conical functions. Those are so much fun when you see them for the first time.

    yeah. Learned something new today.

    SELECT {fn CURRENT_TIMESTAMP(0)}

    SELECT {fn CONCAT({fn CURDATE( )}+' ',{fn CURTIME( )})}

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

  • -- TheTimeIs Script

    -- start script

    CREATE PROC TheTimeIs AS

    SELECT CREATED FROM INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_NAME = 'TheTimeIs';

    GO

    EXEC TheTimeIs;

    DROP PROC TheTimeIs;

    GO

    -- end script

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

  • Jeff Moden (11/19/2015)


    There are many more but, just to wet the appetite for other possibilities...

    SELECT {fn NOW()};

    SELECT {fn CURRENT_DATE()} + ' ' + {fn CURRENT_TIME()};

    EXEC xp_CmdShell 'Date /T & Time /T';

    Thanks for the heads up Jeff!

    Recapping again, weeding out the obviously inaccurate ones and adding some extra information

    😎

    USE tempdb;

    GO

    SET NOCOUNT ON;

    ;WITH DATE_TIME_METHODS(DTM_VAL,DTM_FUNCTION,DTM_DESCRIPTION) AS

    (

    SELECT CONVERT(DATETIMEOFFSET(7),SYSDATETIME(),0)

    ,'sysdatetime()' , 'T-SQL SYSDATETIME()'

    UNION ALL

    SELECT CONVERT(DATETIMEOFFSET(7),SYSDATETIMEOFFSET(),0)

    ,'sysdatetimeoffset()' , 'T-SQL SYSDATETIMEOFFSET()'

    UNION ALL

    SELECT CONVERT(DATETIMEOFFSET(7),SYSUTCDATETIME(),0)

    ,'sysutcdatetime()' , 'T-SQL SYSUTCDATETIME()'

    UNION ALL

    SELECT CONVERT(DATETIMEOFFSET(7),GETUTCDATE(),0)

    ,'getutcdate()' , 'T-SQL GETUTCDATE()'

    UNION ALL

    SELECT CONVERT(DATETIMEOFFSET(7),GETDATE(),0)

    ,'getdate()' , 'T-SQL GETDATE()'

    UNION ALL

    SELECT CONVERT(DATETIMEOFFSET(7),CURRENT_TIMESTAMP,0)

    ,'getdate()' , 'T-SQL CURRENT_TIMESTAMP'

    UNION ALL

    SELECT CONVERT(DATETIMEOFFSET(7),{fn NOW()},0)

    ,'getdate()' , 'ODBC fn NOW()'

    UNION ALL

    SELECT CONVERT(DATETIMEOFFSET(7),{fn CURRENT_TIMESTAMP ()},0)

    ,'fn current_timestamp()' , 'ODBC fn CURRENT_TIMESTAMP ()'

    UNION ALL

    SELECT CONVERT(DATETIMEOFFSET(7),{fn CURRENT_DATE()} + ' ' + {fn CURRENT_TIME()},0)

    ,'getdate()' , 'ODBC fn CURRENT_DATE() + fn CURRENT_TIME()'

    UNION ALL

    SELECT CONVERT(DATETIMEOFFSET(7),{fn CURDATE()} + ' ' + {fn CURTIME()},0)

    ,'getdate()' , 'ODBC fn CURDATE() + fn CURTIME()'

    UNION ALL

    SELECT CONVERT(DATETIMEOFFSET(7),(SELECT DATEADD(MILLISECOND,total_elapsed_time,start_time)

    FROM sys.dm_exec_requests

    WHERE session_id = @@SPID),0)

    ,'N/A' , 'Dynamic Management View dm_exec_requests with total_elapsed_time correction'

    UNION ALL

    SELECT CONVERT(DATETIMEOFFSET(7),(SELECT MAX(T.StartTime)

    FROM sys.fn_trace_gettable(CONVERT(VARCHAR(150)

    , ( SELECT TOP 1 FI.[value]

    FROM sys.fn_trace_getinfo(NULL) FI

    WHERE FI.property = 2 ),0), DEFAULT) AS T

    WHERE T.SPID = @@SPID),0)

    ,'N/A' , 'Default Trace fn_trace_gettable'

    )

    SELECT

    DT.DTM_VAL

    ,DT.DTM_FUNCTION

    ,DT.DTM_DESCRIPTION

    FROM DATE_TIME_METHODS DT;

    Output

    DTM_VAL DTM_FUNCTION DTM_DESCRIPTION

    ---------------------------------- ---------------------- ---------------------------------------------------------------------------

    2015-11-20 08:17:33.4878951 +00:00 sysdatetime() T-SQL SYSDATETIME()

    2015-11-20 08:17:33.4878951 +00:00 sysdatetimeoffset() T-SQL SYSDATETIMEOFFSET()

    2015-11-20 08:17:33.4878951 +00:00 sysutcdatetime() T-SQL SYSUTCDATETIME()

    2015-11-20 08:17:33.4870000 +00:00 getutcdate() T-SQL GETUTCDATE()

    2015-11-20 08:17:33.4870000 +00:00 getdate() T-SQL GETDATE()

    2015-11-20 08:17:33.4870000 +00:00 getdate() T-SQL CURRENT_TIMESTAMP

    2015-11-20 08:17:33.4870000 +00:00 getdate() ODBC fn NOW()

    2015-11-20 08:17:33.4870000 +00:00 fn current_timestamp() ODBC fn CURRENT_TIMESTAMP ()

    2015-11-20 08:17:33.4870000 +00:00 getdate() ODBC fn CURRENT_DATE() + fn CURRENT_TIME()

    2015-11-20 08:17:33.4870000 +00:00 getdate() ODBC fn CURDATE() + fn CURTIME()

    2015-11-20 08:17:33.4870000 +00:00 N/A Dynamic Management View dm_exec_requests with total_elapsed_time correction

    2015-11-20 08:17:33.4870000 +00:00 N/A Default Trace fn_trace_gettable

  • There are many more but, just to wet the appetite for other possibilities...

    Sounds a bit too damp for my liking. 'Whet' is the word I think you were looking for 🙂

    The absence of evidence is not evidence of absence
    - Martin Rees
    The absence of consumable DDL, sample data and desired results is, however, evidence of the absence of my response
    - Phil Parkin

  • Phil Parkin (11/20/2015)


    There are many more but, just to wet the appetite for other possibilities...

    Sounds a bit too damp for my liking. 'Whet' is the word I think you were looking for 🙂

    HA. Good catch, Phil. @=)

    Brandie Tarvin, MCITP Database AdministratorLiveJournal Blog: http://brandietarvin.livejournal.com/[/url]On LinkedIn!, Google+, and Twitter.Freelance Writer: ShadowrunLatchkeys: Nevermore, Latchkeys: The Bootleg War, and Latchkeys: Roscoes in the Night are now available on Nook and Kindle.

  • Looks like the spam bomb went off this morning...

    Ugh...

  • Nothing like staying up late two nights in a row to do releases, get called back ten minutes after the second release to be told I forgot to move scripts, and then have a brisk discussion with everyone involved to explain why those scripts didn't get moved.

    ME: "Those scripts weren't on the move sheet and I don't move anything that I wasn't told to move."

    Others: "But the scripts are in X folder."

    ME: "Lots of scripts are in that folder. I am not going to run every script in that folder because some of them aren't ready to be moved yet. And you haven't given me a list of scripts to run, and there is nothing from the Y team indicating that there are additional scripts to run. Sorry. Not breaking production on your say so."

    It wasn't quite that bad, but I'm exhausted this morning and everyone's running around here in semi-panic mode. "Where are the scripts?"

    Brandie Tarvin, MCITP Database AdministratorLiveJournal Blog: http://brandietarvin.livejournal.com/[/url]On LinkedIn!, Google+, and Twitter.Freelance Writer: ShadowrunLatchkeys: Nevermore, Latchkeys: The Bootleg War, and Latchkeys: Roscoes in the Night are now available on Nook and Kindle.

Viewing 15 posts - 51,541 through 51,555 (of 66,712 total)

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