Declare @name varchar(255) Declare @tele varchar(255)
declare crs_addresses cursor for Select name,tele from Directory ' The criteria for the records to be returned. for update ' Optional, this is used to denote whether the records will be updated.
open crs_addresses
Fetch First from crs_addresses into @name,@tele
while @@fetch_status = 0 begin print @name + " " + @tele fetch next from crs_addresses into @name,@tele end
close crs_addresses deallocate crs_addresses
declare crs_addresses cursor static for ' Notice the addition of the static keyword. Select name,tele from Directory for update
Declare @name varchar(255) Declare @tele varchar(255) declare crs_addresses cursor for Select name,tele from Directory for update open crs_addresses while @@fetch_status = 0 begin print @name + " " + @tele fetch next from crs_addresses into @name,@tele end close crs_addresses deallocate crs_addresses
*Comments are the views of individuals, they may or may not be correct.All comments are reviewed and accepted or rejected.If you give an email address, you will be sent an email when someone makes a comment on this page.*