Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
latent_ken
Starting Member
10 Posts |
Posted - 2011-08-05 : 17:04:05
|
How do i write a while loop that goes through an entire table? |
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
robvolk
Most Valuable Yak
15732 Posts |
|
Jason W
Starting Member
19 Posts |
Posted - 2011-08-06 : 22:14:47
|
Here is how you can loop through a table, although there is probably a good chance that you can write your query without any looping at all. But here you go:http://www.sqloptimizationsschool.com/Pages/Advanced%20Concepts/Loops%20vs.%20Cursors.aspx |
 |
|
jcelko
Esteemed SQL Purist
547 Posts |
Posted - 2011-08-07 : 01:09:30
|
The short answer is "use a cursor"The RIGHT answer is NEVER use a cursor. SQL words with entire sets of data at one time, not like mag tapes and record at time processing. You need to study RDBMS for about a year before you post again.--CELKO--Books in Celko Series for Morgan-Kaufmann PublishingAnalytics and OLAP in SQLData and Databases: Concepts in Practice Data, Measurements and Standards in SQLSQL for SmartiesSQL Programming Style SQL Puzzles and Answers Thinking in SetsTrees and Hierarchies in SQL |
 |
|
russell
Pyro-ma-ni-yak
5072 Posts |
Posted - 2011-08-07 : 11:09:24
|
Ken, please ignore the rude outburst above.Of course feel free to post when you have questions. |
 |
|
latent_ken
Starting Member
10 Posts |
Posted - 2011-08-16 : 12:10:46
|
Thank you for all the help. I am trying to get it done without looping. The other thread listed above is related to this one so i will ask questions there. |
 |
|
|
|
|