Are the posted questions getting worse?

  • GilaMonster (3/16/2010)


    137 - The inverse of the 'fine structure constant'.

    ...and the 33rd prime number. Retaining the theme of a, you should probably also use 29 (the 10th prime) a lot too.

  • Jeff Moden (3/16/2010)


    Heh... I just can't see writing it this way...

    DATEADD(DAY, DATEDIFF(DAY, CAST('19000101' AS DATETIME), CURRENT_TIMESTAMP), CAST('19000101' AS DATETIME))

    It's not so bad. How about:

    SELECT DATEADD(DAY, DATEDIFF(DAY, {d '1900-01-01'}, CURRENT_TIMESTAMP), {d '1900-01-01'})

    --or

    SELECT DATEADD(DAY, DATEDIFF(DAY, '1900-01-01T00:00:00', CURRENT_TIMESTAMP), '1900-01-01T00:00:00')

    Using CAST or CONVERT is not such a bad habit to get into: you have to write dates that way in a function to make it deterministic, for example.

  • Paul White (3/16/2010)


    GilaMonster (3/16/2010)


    137 - The inverse of the 'fine structure constant'.

    ...and the 33rd prime number. Retaining the theme of a, you should probably also use 29 (the 10th prime) a lot too.

    I use the number 29 a lot... that's the number of hampster poo pellets it takes to fill the flux capacitor on my DBCC TIMEWARP machine.

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

  • 29 is also my record for the number of pork chops I've had in the air at the same time. I was pretty ticked that day... 😛

    --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 (3/16/2010)


    I assume that by "explicit date" you mean something like '1900-01-01'... and that's not a date either... that's a string that looks like a date. 😛

    Aside from using CAST or CONVERT, the following produce a DATETIME directly:

    SELECT d = {d '1900-01-01'}, -- Date only at midnight

    t = {t '00:00:00.000'}, -- Today at midnight

    ts = {ts '1900-01-01 00:00:00.000'} -- Full timestamp

  • Paul White (3/16/2010)


    Jeff Moden (3/16/2010)


    I assume that by "explicit date" you mean something like '1900-01-01'... and that's not a date either... that's a string that looks like a date. 😛

    Aside from using CAST or CONVERT, the following produce a DATETIME directly:

    SELECT d = {d '1900-01-01'}, -- Date only at midnight

    t = {t '00:00:00.000'}, -- Today at midnight

    ts = {ts '1900-01-01 00:00:00.000'} -- Full timestamp

    Very interesting! Apparently, I've been missing out on some good stuff because that works in 2k and 2k5. Keeping in mind that I don't have 2k8, is there a heading in Books Online that I could look under to find out more about such useful shorthand formats such as those above?

    --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 (3/16/2010)


    Very interesting! Apparently, I've been missing out on some good stuff because that works in 2k and 2k5. Keeping in mind that I don't have 2k8, is there a heading in Books Online that I could look under to find out more about such useful shorthand formats such as those above?

    Surely is...ODBC Scalar Functions

  • I was just getting ready to post that I sussed it...

    ODBC timestamp data in Books Online. Was a real SWAG on my part, too! 🙂

    Thanks for the link, Paul... I'll take a look.

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

  • Paul White (3/16/2010)


    Jeff Moden (3/16/2010)


    Very interesting! Apparently, I've been missing out on some good stuff because that works in 2k and 2k5. Keeping in mind that I don't have 2k8, is there a heading in Books Online that I could look under to find out more about such useful shorthand formats such as those above?

    Surely is...ODBC Scalar Functions

    Very interesting.

    Thanks for the link.

    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

  • Jeff Moden (3/16/2010)


    Was a real SWAG on my part, too! 🙂

    Scientific wild-*** guess?

    Special Warfare Action Group?

    Silly wild-*** guess?

    Stuff we all get?

    Smart wild-*** guess?

    Software wild-*** guesstimate?

    Sold without a guarantee?

  • Paul White (3/16/2010)


    Jeff Moden (3/16/2010)


    Was a real SWAG on my part, too! 🙂

    Scientific wild-*** guess?

    Special Warfare Action Group?

    Silly wild-*** guess?

    Stuff we all get?

    Smart wild-*** guess?

    Software wild-*** guesstimate?

    Sold without a guarantee?

    Nah... I turned on the SWAG lamp so I could see my notes. 😛

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

  • Most of the ODBC Scalar functions have direct equivalents in T-SQL. But... this one is very interesting...

    SELECT d = {fn CURRENT_DATE()}

    I've gotta see if I can find more goodies like that...

    --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 (3/16/2010)


    Most of the ODBC Scalar functions have direct equivalents in T-SQL. But... this one is very interesting...

    SELECT d = {fn CURRENT_DATE()}

    Yes. Mentioned it a few posts back - it unfortunately uses string conversion from getdate(), using the undocumented style '23'.

    {t ''00:00:00.000} is nice for getting midnight today.

  • Now that you mention it, I remember that post. That was before I turned on the SWAG light, though. :hehe:

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

  • john.arnott (3/16/2010)


    Paul White (3/12/2010)


    Jeff Moden (3/12/2010)


    We're rootin' for ya!

    * snigger *

    See the entry for root here

    And when you go to London, do you wear a fanny-pack? (Hey. He started it....)

    Oooh. Don't say fanny-pack in England. I already made that mistake.

    "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

Viewing 15 posts - 12,826 through 12,840 (of 66,712 total)

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