• RamSteve (10/7/2013)


    Hi I have 2 Tables as below , I need to delete TableA row with ConsumerID = 99 as my condition would be to delete the rows in Table A if DeleteFlag in Table B is 1 for the columns ConsumerID and Product

    Can some one help me deleting the Table A With Consumer ID = 99 with sql script

    thanks in Advance 🙂

    Table A :

    ConsumerID, xxxx, AAAAA, BBBB

    99 1 2 3

    100 2 3 4

    Table B :

    ConsumerID, Product, DeleteFlag, dddd

    99 1 1 4

    99 2 1 5

    100 1 0 6

    100 5 1 3

    There are obviously some additional business rules missing from your description. Why would you not also delete ConsumerID 100? There is a row with DeleteFlag of 1 in TableB.

    As previously stated, this looks a lot like homework. We will help you figure out a solution but we don't do homework for you. If you we do the work, you don't learn anything.

    _______________________________________________________________

    Need help? Help us help you.

    Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

    Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.

    Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
    Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
    Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
    Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/