Re: using t-sql cursors ...
From: Tamas Bojcan - bojci (bojcan_at_freemail.hu)
Date: 08/19/04
- Next message: Ian: "Really tough ADO Stored Procedure Question. Please Help!!!"
- Previous message: Uri Dimant: "Re: Life of database options and resetting the defaults"
- In reply to: VADOR: "Re: using t-sql cursors ..."
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 19 Aug 2004 11:38:33 +0200
You are right, use WHILE loop... See this from the BOL:
USE pubs
GO
DECLARE @au_lname varchar(40), @au_fname varchar(20)
DECLARE authors_cursor CURSOR FOR SELECT au_lname, au_fname FROM authors
WHERE au_lname LIKE "B%" ORDER BY au_lname, au_fname
OPEN authors_cursor
FETCH NEXT FROM authors_cursor INTO @au_lname, @au_fname
WHILE @@FETCH_STATUS = 0
BEGIN
PRINT "Author: " + @au_fname + " " + @au_lname
FETCH NEXT FROM authors_cursor INTO @au_lname, @au_fname
END
CLOSE authors_cursor
DEALLOCATE authors_cursor
GO
"VADOR" <anonymous@discussions.microsoft.com> wrote in message
news:919501c485cf$621f7610$a601280a@phx.gbl...
> Thanks for vary fast reaction. I know that i can't fetch
> multiple rows directly using 'fetch next' but how to
> resolve this problem using t-sql. Maybe using 'while' loop
> with 'fetch next into' and 'table' variable?
> >-----Original Message-----
> >Hi,
> >
> >You can't do this. Maybe you thought for multiple
> columns? It's possible and
> >you can find examples in the BOL.
> >
> >
> >"VADOR" <anonymous@discussions.microsoft.com> wrote in
> message
> >news:8b5501c485bf$d0569740$a501280a@phx.gbl...
> >> Hello,
> >> please show me an example (real t-sql code), how to
> >> retrieve multiple rows in each fetch from rowset using
> t-
> >> sql cursors.
> >> Regards
> >>
> >
> >
> >.
> >
- Next message: Ian: "Really tough ADO Stored Procedure Question. Please Help!!!"
- Previous message: Uri Dimant: "Re: Life of database options and resetting the defaults"
- In reply to: VADOR: "Re: using t-sql cursors ..."
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|