Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
i want to perform this 'for loop' in stored procedure
 
for (int i=0;i<4;i++)
update table
Posted 1-Apr-11 0:31am
Edited 1-Apr-11 1:23am
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

DECLARE @Iterator INT
SET @Iterator = 0
 
WHILE (@Iterator < 4)
BEGIN
    UPDATE 
        SomeTable
    SET
        SomeField = @Iterator
    WHERE
        AnotherField = SomeCritiria
 
    Set @Iterator = @Iterator + 1
END 
  Permalink  
v2
Comments
shms_rony at 1-Apr-11 7:18am
   
i have error
 
"must declare scalar variable @Iterator"
Dylan Morley at 1-Apr-11 7:27am
   
My declare was wrong way round, see updated solution
shms_rony at 1-Apr-11 7:28am
   
thank you
Member 10557224 at 17-Feb-14 8:19am
   
thanks...
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Hope this[^] might help you.
  Permalink  
Comments
shms_rony at 1-Apr-11 6:41am
   
i want to perform the statement using syntax of sql server 2005
Henry Minute at 1-Apr-11 7:10am
   
The link given to you WAS in SQL.
 
Stop down-voting people that are trying to help you, or you will find that no-one will try.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

  Permalink  
Comments
shms_rony at 1-Apr-11 6:41am
   
i don't find what iwant in google ...so i put my question here
Sandeep Mewara at 1-Apr-11 6:54am
   
Oh wow! You don't find when every link speaks of it when you Google... and then you downvote.
 
Thanks. Carry on with your work. Good attitude! :)
Rohan Leuva at 2-May-13 4:55am
   
+5
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

very good way to deliver the solution, easy to understand thx codeProject and its membranes
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



Advertise | Privacy | Mobile
Web03 | 2.8.141015.1 | Last Updated 24 Jan 2014
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100