September 9, 2014 at 10:26 pm
Comments posted to this topic are about the item While loop Testing
Thanks,
Shiva N
Database Consultant
September 10, 2014 at 12:50 am
Interesting, albeit megalomaniacal question 😀
Need an answer? No, you need a question
My blog at https://sqlkover.com.
MCSE Business Intelligence - Microsoft Data Platform MVP
September 10, 2014 at 12:53 am
Woww .... to many nested While loops 🙂
Nice question, as its reminded the nested loop depth. Thanks for sharing.
I wonder what Jeff Moden have to say about this ... :hehe:
September 10, 2014 at 1:24 am
You have a bug in your code here: SET @strend = @strend + ' SET @intloopCounter=@intloopCounter+1 END '
and the variable should be @intLoopCounter, case letters depends. With your code on any SQL place it throws errors.
September 10, 2014 at 1:40 am
Tricky....
good one...
Vimal LohaniSQL DBA | MCP (70-461,70-462)==============================The greatest barrier to success is the fear of failure ** Success is a journey not a destination**Think before you print, SAVE TREES, Protect Mother Nature
September 10, 2014 at 2:46 am
This was removed by the editor as SPAM
September 10, 2014 at 2:49 am
Good question, if you read it carefully you will get the answer right.
Thanx
Thanks & Best Regards,
Hany Helmy
SQL Server Database Consultant
September 10, 2014 at 3:20 am
Nice one .....
September 10, 2014 at 3:22 am
twin.devil (9/10/2014)
Woww .... to many nested While loops 🙂Nice question, as its reminded the nested loop depth. Thanks for sharing.
I wonder what Jeff Moden have to say about this ... :hehe:
Yep...
September 10, 2014 at 3:58 am
Due to an error in the variable name I chose the wrong answer. Interesting to read more about while loop levels, although who would ever need/create a query with that many while loops is baffling me. 😉
September 10, 2014 at 5:29 am
An interesting question to be sure, but as a general rule, I can't stand loops. On those rare occasions when they're necessary, I'll begrudgingly use one, but I still don't like them.
September 10, 2014 at 5:31 am
I think the only thing I take away from this question is confirmation that dynamic SQL must be avoided, but if you need it you should at least name your variables with a little more care...
September 10, 2014 at 7:31 am
Personally I detest questions like this. This is testing our ability to be a human compiler and debug code that faced with in the real world I would toss out and rewrite. To me this does not follow the spirit of the QOTD which is to test our knowledge of various aspects of sql server. It doesn't help that the site does a rather lousy job of formatting. While I don't like the question I applaud the effort and hope to see more questions from Shiva in the future.
_______________________________________________________________
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/
September 10, 2014 at 8:08 am
Thanks Shiva
Jason...AKA CirqueDeSQLeil
_______________________________________________
I have given a name to my pain...MCM SQL Server, MVP
SQL RNNR
Posting Performance Based Questions - Gail Shaw[/url]
Learn Extended Events
September 10, 2014 at 8:31 am
I got a different error than was indicated,
Msg 102, Level 15, State 1, Line 1289
Incorrect syntax near 'END'.
But when I reduced @intMaxLoop from 162 to 161, it worked. So I chose that option, which was wrong. Humph.
Viewing 15 posts - 1 through 15 (of 20 total)
You must be logged in to reply to this topic. Login to reply