Forum Replies Created

Viewing 15 posts - 3,646 through 3,660 (of 7,609 total)

  • RE: UPDATE with JOINS and WHERE clause

    When joining to do UPDATEs, always update the table alias not the table name itself.  Otherwise you could have the same problem (or other problems).


    UPDATE ...

  • RE: Conditional CONDITION - CASE in WHERE

    Specifically what row selection conditions do you want?  Your sample is not clear.  But you almost certainly don't need CASE in any event.

    It sounds like you may actually...

  • RE: Looking for an optimal solution

    Could you provide actual test data, as CREATE TABLE and INSERT statements, rather than just a picture of data.  We can't write code against a picture .🙂

  • RE: ORDER By Based on Company then SubCompany

    There's no need to join the group row to itself, so this is another possibility:


    SELECT c.*
    FROM #companies c
    LEFT OUTER JOIN #companies g
     ...

  • RE: No of Months between two dates in YYYYMM format

    If the values are integers, I don't see the need to involve date conversions/char stringing at all:


    SELECT yyyymm1, yyyymm2, (yyyymm2 / 100 * 12 +...

  • RE: Remove duplicate values

    jcelko212 32090 - Thursday, December 7, 2017 11:51 AM

    saravanatn - Wednesday, December 6, 2017 1:00 AM

    December 7, 2017 at 3:16 pm

    #1971286

  • RE: Index question

    For those indexes, you could drop both index1 and index2.

  • RE: Question about the GO statement

    sgmunson - Thursday, December 7, 2017 7:21 AM

    ScottPletcher - Wednesday, December 6, 2017 3:30 PM

  • RE: Question about the GO statement


    /* this block should only get executed on the first iteration */
    DECLARE @greeting VARCHAR(100);
    SET @greeting = 'Hello';
    /* ==================== */
    /* I want this block...

  • RE: Find Differences Between Two Tables

    FYI, fwiw, there's some slight differences in the sample data being used and the original sample data picture.  Here's the adjusted data:


    INSERT INTO...

  • RE: Query Help -

    Ed Wagner - Monday, December 4, 2017 3:44 PM

    ScottPletcher - Monday, December 4, 2017 3:36 PM

    December 4, 2017 at 3:46 pm

    #1970632

  • RE: Query Help -

    Ed Wagner - Monday, December 4, 2017 3:33 PM

    ScottPletcher - Monday, December 4, 2017 12:59 PM

    December 4, 2017 at 3:36 pm

    #1970628

  • RE: Query Help -

    I allow my instances to auto-parameterize, so if it's that valuable to the plan, presumably SQL will do so anyway.

    Again, with dynamic SQL specifically -- which this code...

  • RE: Query Help -

    Lynn Pettis - Monday, December 4, 2017 1:22 PM

    ScottPletcher - Monday, December 4, 2017 12:59 PM

    December 4, 2017 at 2:19 pm

    #1970614

  • RE: Query Help -

    Ed Wagner - Monday, December 4, 2017 12:11 PM

    Lynn Pettis - Monday, December 4, 2017 11:44 AM

Viewing 15 posts - 3,646 through 3,660 (of 7,609 total)