• riya_dave (8/1/2013)


    but i need loop or condtion hwo to do it

    example if primarycondition = 'HF'

    then update table a

    set secondary condtion = null

    if there is no primary condition = 'HF'

    then

    if primarycondition = 'CAD'

    update table a

    set secondarycondition = primarycondition

    except for primarycondition ='CAD'

    Use ROW_NUMBER.

    If you need specific help with syntax you MUST post ddl and sample data in a consumable format. If you can do that you will get tested and accurate code back very quickly. If you continue to refuse to help us to help you, you will continue to get answers with no real details.

    You should read this article and think about how this relates to what you have posted in this thread.

    http://weblogs.sqlteam.com/jeffs/archive/2008/05/13/question-needed-not-answer.aspx

    _______________________________________________________________

    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/