Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Multiple Row update with loops

Author  Topic 

Swati Jain
Posting Yak Master

139 Posts

Posted - 2010-01-14 : 05:59:47
I want to update multiple rows of the column

How can i do this using for loop??

Or writing Cursor is required.

Because i want to avoid the use of cursors . how i can write loops performing same update operation

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2010-01-14 : 06:08:45
Do you have an example?


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-01-14 : 09:54:26
quote:
Originally posted by Swati Jain

I want to update multiple rows of the column

How can i do this using for loop??

Or writing Cursor is required.

Because i want to avoid the use of cursors . how i can write loops performing same update operation


you dont need loops in most cases. you can go for set based solution. but to advise further we need to know actual scenario. would you mind explaining your scenario with some sample data?
Go to Top of Page

sudheepdivakar
Starting Member

5 Posts

Posted - 2010-01-14 : 12:03:50
you can use while loop. i dont think sql have for loop.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-01-14 : 12:11:31
quote:
Originally posted by sudheepdivakar

you can use while loop. i dont think sql have for loop.


you should try to go for set based solution as far as you can . use of cursors and loops can hurt performance
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2010-01-14 : 14:02:37
Posting some details would help

Like the DDL for the table, what's suppose to be updated, where the data for the updates are coming from...you know, little details that actual show us what you are trying to do....

Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam



Go to Top of Page
   

- Advertisement -