July 6, 2012 at 1:44 pm
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
July 6, 2012 at 1:46 pm
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.
July 6, 2012 at 1:59 pm
This table contains trigger, that's why I wanted to do it like this in a loop.
July 6, 2012 at 2:02 pm
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
July 6, 2012 at 2:04 pm
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.
July 6, 2012 at 2:05 pm
Then your trigger needs to be modified to handle multiple rows.
July 9, 2012 at 8:56 am
Here is my steps in detail.
July 9, 2012 at 2:26 pm
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
July 9, 2012 at 2:44 pm
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.
July 9, 2012 at 2:45 pm
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