July 19, 2013 at 1:25 pm
hi
in my stored proc i have 3-4 while loop and i need to use different variable for it
i m having my code under begin and end. so is there any way i can use same variable name for different while loop.
July 19, 2013 at 1:28 pm
riya_dave (7/19/2013)
hiin my stored proc i have 3-4 while loop and i need to use different variable for it
i m having my code under begin and end. so is there any way i can use same variable name for different while loop.
nope.
Do you really need any while loops, let alone 3 or 4 of them? Your code will run light years faster if you get rid of these loops.
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
July 19, 2013 at 1:35 pm
i need while loop ,but my question is do i need to declare different variables each time
July 19, 2013 at 1:42 pm
riya_dave (7/19/2013)
i need while loop ,but my question is do i need to declare different variables each time
As I said before, you cannot use the same name declared multiple times in a single stored proc. You either need to use different names or reuse the existing variable.
I doubt you actually need your loop but to each his own.
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
July 19, 2013 at 1:44 pm
It's hard to really reply to what you're saying without seeing it. Is each variable inside a different while loop? Post an example, or better yet, post what you've written and I'm sure that a lot of people here could help you very quickly. Really, it's to your own advantage to provide as much data as possible for the quickest and most accurate response.
July 19, 2013 at 1:51 pm
riya_dave (7/19/2013)
i need while loop
Is it because you don't know how to do it without a loop?
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply