February 22, 2007 at 4:36 pm
hi,
i have a stored proc that have seies of inner joins.now im planning to apply a cursor .how an i do that?
thanks!
February 22, 2007 at 4:54 pm
You must provide more information which will include
For an example of cursor, see below:
DECLARE titles_cursor CURSOR FOR
SELECT t.title
FROM titleauthor ta, titles t
WHERE ta.title_id = t.title_id AND
ta.au_id = @au_id -- Variable value from the outer cursor
OPEN titles_cursor
FETCH NEXT FROM titles_cursor INTO @title
WHILE @@FETCH_STATUS = 0
BEGIN
SELECT @message = " " + @title
PRINT @message
FETCH NEXT FROM titles_cursor INTO @title
END
CLOSE titles_cursor
DEALLOCATE titles_cursor
February 22, 2007 at 4:54 pm
Why use a cursor at all??
What do you need to do exactly?
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply