how to use for loop in stored procedure in sql2005

Posted by Gow.Net under Sql Server on 9/13/2012 | Points: 10 | Views : 20592 | Status : [Member] | Replies : 4
how to use for loop in stored procedure in sql2005

gowthaman8870226416


Responses

Posted by: Hariinakoti on: 9/13/2012 [Member] Starter | Points: 25

Up
0
Down
follow this link
http://www.dotnetfunda.com/forums/thread2191-for-loop-in-stored-procedure-in-sql-server-2005.aspx

Thanks & Regards
Hari

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

Posted by: Ranjeet_8 on: 9/27/2012 [Member] [MVP] Gold | Points: 25

Up
0
Down
Try this instead of for loop

DECLARE @intFlag INT
SET @intFlag = 1
WHILE (@intFlag <=5)
BEGIN
PRINT @intFlag
SET @intFlag = @intFlag + 1
END
GO

OUTPUT

1
2
3
4
5


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

Posted by: Jayakumars on: 9/27/2012 [Member] [MVP] Bronze | Points: 25

Up
0
Down
hi

use loop purpose Cursor is best
refer this


http://sqlusa.com/bestpractices2005/doublecursor/


Mark as Answer if its helpful to you

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

Posted by: Jayakumars on: 9/27/2012 [Member] [MVP] Bronze | Points: 25

Up
0
Down
hi
Please mark as answer if it helpful to you.

Mark as Answer if its helpful to you

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

Login to post response