Issue with Trd_linked column

  • Hi,

    I have a requirement to check why the Trd_Linked column is getting 'N' for legal 206337

    UPDATE #Rpt SET Trd_Linked = 'N' --setting default value as N

    UPDATE #Rpt SET Trd_Linked = 'Y'

    FROM #Rpt RT

    INNER JOIN customer..bus_a_lgle_tree BT ON RT.bus_a_id_c = BT.bus_a_id_c AND RT.lgle_id_c = BT.lgle_id_c

    WHERE BT.lgle_sys_a_rel_c = 'TRD'

    Based on this condition i got teh excel sheet with bus id's 205605 and 205629 have same

    legal id 206337 but the Trd_Linked column is showing as 'N'

    when i ran this query select * from customer..bus_a_lgle_tree where lgle_id_c = 206337 i got only

    bus_a_id_c a s 205605 there is no 205629

    can any one fix it how to find why trd_linked column is getting N fo rlegal 206337.

  • First, it doesn't matter what you might have in Excel. You need to know what's in SQL Server.

    Second, formatting your code will make a lot of this easier for everyone.

    Third, where is the problem with the trd_linked column? In your #rpt table or the bus_a_lgle_tree table?

    Don't start with updates. First, build a SELECT. So something like this:

    SELECT Trd_Linked

    FROM #Rpt RT

    INNER JOIN customer..bus_a_lgle_tree BT

    ON RT.bus_a_id_c = BT.bus_a_id_c

    AND RT.lgle_id_c = BT.lgle_id_c

    WHERE BT.lgle_sys_a_rel_c = 'TRD'

    Do you get a value for 206337

    select *

    from customer..bus_a_lgle_tree

    where lgle_id_c = 206337

    Your join should pull back matching values from the tables. If you don't have the correct bus_ids for the legal ID, then you might not get the correct update. Perhaps you have the wrong lgle_sys_a_rel_c value in a row.

  • shalini72011 (11/10/2011)


    Hi,

    I have a requirement to check why the Trd_Linked column is getting 'N' for legal 206337

    UPDATE #Rpt SET Trd_Linked = 'N' --setting default value as N

    UPDATE #Rpt SET Trd_Linked = 'Y'

    FROM #Rpt RT

    INNER JOIN customer..bus_a_lgle_tree BT ON RT.bus_a_id_c = BT.bus_a_id_c AND RT.lgle_id_c = BT.lgle_id_c

    WHERE BT.lgle_sys_a_rel_c = 'TRD'

    Based on this condition i got teh excel sheet with bus id's 205605 and 205629 have same

    legal id 206337 but the Trd_Linked column is showing as 'N'

    when i ran this query select * from customer..bus_a_lgle_tree where lgle_id_c = 206337 i got only

    bus_a_id_c a s 205605 there is no 205629

    can any one fix it how to find why trd_linked column is getting N fo rlegal 206337.

    It's getting N because of this statement.

    UPDATE #Rpt SET Trd_Linked = 'N' --setting default value as N

    I think you really want to know why it's NOT getting Y. You haven't given us enough information to determine that, but there are only two possibilities: it doesn't meet the JOIN criteria or the WHERE criteria in your second UPDATE.

    Drew

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

Viewing 3 posts - 1 through 2 (of 2 total)

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