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
 General SQL Server Forums
 New to SQL Server Programming
 Cusor - weird results

Author  Topic 

Chris_Kelley
Posting Yak Master

114 Posts

Posted - 2014-08-09 : 10:48:49
c

namman
Constraint Violating Yak Guru

285 Posts

Posted - 2014-08-09 : 11:34:28
DECLARE TEST_CURSOR CURSOR FAST_FORWARD
FOR
SELECT FIRSTNAME,LASTNAME,BIRTHDAY FROM #TEST ORDER BY BIRTHDAY ASC
OPEN TEST_CURSOR
FETCH NEXT FROM TEST_CURSOR
INTO @FIRSTNAME,@LASTNAME,@BIRTHDAY
PRINT @FIRSTNAME + ' ' + @LASTNAME + ' ' + @BIRTHDAY
WHILE @@FETCH_STATUS = 0
BEGIN
-- code should be here
PRINT @FIRSTNAME + ' ' + @LASTNAME + ' ' + @BIRTHDAY
-- ------
FETCH NEXT FROM TEST_CURSOR
INTO @FIRSTNAME,@LASTNAME,@BIRTHDAY
PRINT @FIRSTNAME + ' ' + @LASTNAME + ' ' + @BIRTHDAY
END
CLOSE TEST_CURSOR
DEALLOCATE TEST_CURSOR
Go to Top of Page

Chris_Kelley
Posting Yak Master

114 Posts

Posted - 2014-08-09 : 12:36:27
c
Go to Top of Page
   

- Advertisement -