Forum Replies Created

Viewing 15 posts - 2,281 through 2,295 (of 15,381 total)

  • RE: Painful datetime conversion

    Luis Cazares (9/17/2015)


    If anyone wonders about performance on the posted solutions.

    CREATE TABLE Testing

    (

    VHRGDT numeric(8, 0) NOT NULL,

    VHRGTM numeric(6, 0) NOT NULL

    )

    INSERT INTO Testing

    SELECT TOP 1000000

    CONVERT(...

  • RE: Painful datetime conversion

    Jeff Moden (9/17/2015)


    Sean Lange (9/17/2015)


    The table is small right now because the system is not yet in production but it isn't likely to get too huge. Maybe 100 or so...

  • RE: Painful datetime conversion

    Ed Wagner (9/17/2015)


    Jeff Moden (9/17/2015)


    Man o' man... guess I need to find out what the hell's the matter with my Dev box at work. Here are the run results...

  • RE: Painful datetime conversion

    Kristen-173977 (9/16/2015)


    ... but somewhere on my travels I saw this which satisfies my perception that an arithmetic algorithm will perform better than a string one, but the formula is a...

  • RE: Painful datetime conversion

    Eric M Russell (9/17/2015)


    Someone had mentioned that the date/time conversions can be expensive. Depending on what you're needing to do with the dates and times once they're converted, it might...

  • RE: Painful datetime conversion

    Ed Wagner (9/17/2015)


    To test it, I created a table with column names that don't remind me of days past. Sean, I think you know what I'm talking about. 😉

    I...

  • RE: Painful datetime conversion

    In case anybody is interested I compiled all the suggestions into a single query just so you can see them side by side. 😉

    select DesiredDateTimeValue

    , cast(FORMAT(VHRGDT, '0000-00-00') + ' '...

  • RE: Painful datetime conversion

    tripleAxe (9/17/2015)


    Hi Sean, was your code as nasty looking as mine below?

    SELECT

    DATEADD(SECOND, CONVERT(INT, SUBSTRING(RIGHT('0' +(CONVERT(VARCHAR(6), VHRGTM)),6),1,2)) * 60 * 60 + CONVERT(INT, SUBSTRING(RIGHT('0' +(CONVERT(VARCHAR(6), VHRGTM)),6),3,2)) * 60...

  • RE: Painful datetime conversion

    Jeff Moden (9/16/2015)


    Sean Lange (9/16/2015)


    drew.allen (9/16/2015)


    Try the FORMAT function. It was added in SQL 2012.

    SELECT FORMAT(vhrgdt, '0000-00-00') + ' ' + FORMAT(vhrgtm, '00:00:00.000'), *

    FROM #Something s

    Drew

    Thanks Drew. I don't use...

  • RE: Painful datetime conversion

    drew.allen (9/16/2015)


    Try the FORMAT function. It was added in SQL 2012.

    SELECT FORMAT(vhrgdt, '0000-00-00') + ' ' + FORMAT(vhrgtm, '00:00:00.000'), *

    FROM #Something s

    Drew

    Thanks Drew. I don't use FORMAT very often but...

  • RE: Multiple queries in the same stored procedure

    Manic Star (9/16/2015)


    My co-dba and I wrote some really bad poetry:

    one proc to rule them

    one proc to bind them

    one proc to bring them all and in the darkness, deadlock them

    'precious...

  • RE: Finding NULL in CASE Statement

    Lynn Pettis (9/16/2015)


    Kristen-173977 (9/16/2015)


    Sean Lange (9/16/2015)


    But surely you aren't joining on these string values right???

    Correct. Main thing I would be expecting to find would be an @MyColumn parameter to an...

  • RE: Finding NULL in CASE Statement

    Kristen-173977 (9/16/2015)


    P.S. On the day that that one ACTUALLY comes up I will be ROYALLY pissed off!!

    LOL true dat!!!

  • RE: Finding NULL in CASE Statement

    Kristen-173977 (9/16/2015)


    Sean Lange (9/16/2015)

    This is where consistently using aliases has some advantages. Maybe Staff is st and Supplier is su. ... What I really don't like about prefixes is it...

  • RE: Finding NULL in CASE Statement

    Kristen-173977 (9/16/2015)


    Sean Lange (9/16/2015)


    c.FirstName is obviously the Customer table but s.FirstName indicates the Staff table.

    For me, that's where it starts to fall down. I don't know if S is...

Viewing 15 posts - 2,281 through 2,295 (of 15,381 total)