Saturday, 11 June 2011

woking with cursor simple Example


         Cursor Simple Use Simple Example

create proc order1 
(
 @id varchar(12)
)
as
delete from we
declare @id1 as varchar(12)
declare  cur_name cursor  for
select orderid from orderdetails where product_id=@id
open cur_name
fetch next from cur_name into @id1
while(@@FETCH_STATUS=0)
begin
  insert into we(id)values(@id1)
fetch next from cur_name into @id1
end
CLOSE cur_name  
DEALLOCATE cur_name
select* from we


continue ....more

No comments:

Post a Comment