Forum Replies Created

Viewing 15 posts - 2,506 through 2,520 (of 4,085 total)

  • RE: Add New Column with RowID

    J Livingston SQL (8/1/2016)


    suggest you change

    indexid = ROW_NUMBER() OVER (PARTITION BY [Name] ORDER BY [Name])

    I was going to mention that it's pointless to use the same expression in both the...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Insertig failed records into a different table than good records.

    Ralph L. Wahlert (8/1/2016)


    Thanks John.

    If this is how I have my data flow tasks configured, see below, where would I place the error output?

    Between the lookup and the...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: A twist on recursive query

    michael.lock@aer.ca (7/26/2016)


    You've hit upon the "twist" part. I could be approaching this wrong. I'm assuming a recursion approach because to me this looks like a classic instance of...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: GET MAX VALUE

    I haven't seen anyone mention LAST_VALUE, yet.

    SELECT

    mt.Applicants_ID,

    mt.APPL_CURRENT_STATUS,

    mt.APPL_CURRENT_STATUS_DATE,

    LAST_VALUE(mt.APPL_CURRENT_STATUS) OVER(PARTITION BY mt.Applicants_ID ORDER BY mt.APPL_CURRENT_STATUS_DATE ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) AS lv

    FROM #myTable mt

    I use ROW_NUMBER() if I want to...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: A twist on recursive query

    Why do you think that recursion is the correct approach here? I don't think it is, because a recursive query needs to maintain the same "shape" throughout and I...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Are the posted questions getting worse?

    djj (7/26/2016)


    Eirikur Eiriksson (7/26/2016)


    Sean Lange (7/26/2016)


    Jack Corbett (7/26/2016)


    Apparently the person I'm going to be interviewing shortly has access to and knows how to use DBCC TimeWarp since they...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Flattening Nested Views

    I think that it's possible, but it's going to be very complex, and it might just be easier to do it manually.

    Here are some of the issues that you'll need...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Complex join and sorting the parent and child data

    J Livingston SQL (7/26/2016)


    is it as simple as this ....??

    SELECT * FROM (

    SELECT * FROM #City

    UNION ALL

    SELECT * FROM #Subcity) x

    ORDER BY Years DESC, Citycode, subcitycode

    edit....just rechecked my results.....aint...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Get date from midnight to midnight

    Alternatively, you could cast your DATETIME data as DATE and compare those.

    WHERE CAST(DateCol AS DATE) = CAST(DATEADD(DAY, -1, GETDATE()) AS DATE)

    Since CASTing from DATETIME to DATE is still SARGable, this...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Transaction Rollback on tables with referential integrity

    As long as they are in the same transaction, changes to table A do not need to be committed in order to be available to table B. Generally, people...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Using Values from Update Search statement with insert.

    fergfamster (7/22/2016)


    John-

    Please bare with me, Im sure you have done this a million times. So I add the output inside the Update statement as below then I can query that...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: How To Get Last Inserted Record Value In SQL Server

    JasonClark (7/22/2016)


    we can use SELECT @@IDENTITY, SELECT SCOPE_IDENTITY(), SELECT IDENT_CURRENT(‘TableName’) to get last inserted record: https://mostafaelmasry.com/2016/05/09/how-to-find-the-last-inserted-record-in-sql-server/%5B/url%5D

    Since all of these methods depend on the table having an identity column, and the...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: SP w/ Dynamic SQL Works, Sometimes

    djj (7/21/2016)


    homebrew01 (7/21/2016)


    djj (7/21/2016)


    Should @SQL_CMD be NVARCHAR?

    Do you think that would make a difference in my case ?

    All our similar SP code uses VARCHAR.

    I just remember that one of the...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Getting last good data for each id from each column

    Actually, I think that the Quirky Update[/url] method might be the fastest approach to doing this. You have to be very careful to follow ALL of the rules.

    Drew

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Getting last good data for each id from each column

    That's because LAG is for a relative position. FIRST_VALUE and LAST_VALUE are for absolute positions. You do have to get a little tricky, because you need to ensure...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

Viewing 15 posts - 2,506 through 2,520 (of 4,085 total)