Looping in sql server 2005

Posted by Tejashree under Sql Server on 11/28/2011 | Points: 10 | Views : 996 | Status : [Member] | Replies : 3
Hi All,

I have written one stored procedure, In that I want number of records in table.
I got number of records using COUNT. Now for that many records I want to UPDATE one field Flagcounter by setting its value to 1.
How to do this?
Please guide me.




Responses

Posted by: SheoNarayan on: 11/28/2011 [Administrator] HonoraryPlatinum | Points: 25

Up
0
Down
Based on my understanding based on what you have written; below code snippet will update all records' Flagcounter that match the fieldName = 'something'.

You do not need to loop through

Update yourTableName SET Flagcounter = 1 WHERE fieldName = 'something'

Hope this will help.

Thanks

Regards,
Sheo Narayan
http://www.dotnetfunda.com

Tejashree, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Blessyjees on: 11/28/2011 [Member] Bronze | Points: 25

Up
0
Down
Hi,

Do you have any condition for updating the rows? if so you can specify this in where clause

Blessy Baby
Digitalmesh Softech pvt Ltd
https://blessybaby.wordpress.com/

Tejashree, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Tejashree on: 11/28/2011 [Member] Starter | Points: 25

Up
0
Down
Hi,

It worked.

Thanks a lot!!

Tejashree, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response