Update records

  • Hello,

    I need to update records, but not as a regular upadte as :

    Update table1

    set

    employeename = 'Steven'

    where id= '25'

    But in a loop, record by record,can some one help me with that please.

    Thank you

  • With as little information as you provided, other than telling you to lookup cursors in BOL, nope.

    First question I have is why do you have to it row by row? That is not very efficient or scalable.

  • This table contains trigger, that's why I wanted to do it like this in a loop.

  • Huh? What does a trigger have to do with methods of update?

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • Please provide more information.

    1. How do you want to update the table?

    2. What is the logic in the loop?

    3. Are you going to update one table or multiple tables?

    Regards,
    Ravi.

  • Then your trigger needs to be modified to handle multiple rows.

  • Here is my steps in detail.

  • Krasavita (7/9/2012)


    Here is my steps in detail.

    think your post has been mislaid....nothing here

    ________________________________________________________________
    you can lead a user to data....but you cannot make them think
    and remember....every day is a school day

  • Krasavita (7/9/2012)


    Here is my steps in detail.

    What happened to your attachment? I saw one when checking this post a while ago on my phone.

  • i have encountered a situation where i could only update 1 row at a time and the way i worked around was to use a cursor.

    You could like the others suggest alter the underlying trigger to allow for multiple updates but, that all depends on you being able to!! at the time of my issue, i could not amend the underlying constraints triggers forcing me to be only able to update 1 row at a time.

    Cursors may not be the most efficient way but they will achieve what you have asked :w00t:

    ***The first step is always the hardest *******

Viewing 10 posts - 1 through 9 (of 9 total)

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