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.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 'while' statement to loop through a recordset

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2001-01-03 : 17:43:03
Jeffrey writes "assuming, i have a select statement and i want to loop through every record and perform some if...else statements on each record depending on what are the conditions i'll specify.

is it possible for such operations to be done. here's a simple pseudocode:
------------------------------------------------------------
select id1, current_date from sample1
while not eof
this_id = id1
if current_date is less than today
execute spSample1
else
execute spSample2
end if
delete from sample1 where id1 = this_id
endwhile
------------------------------------------------------------

do u get what i've explained above? otherwise, i'll reply with a more detailed scenario.

SQL Server 7.0
Windows 2000 Professional"
   

- Advertisement -