游标示例

< DOCTYPE html PUBLIC -WCDTD XHTML StrictEN httpwwwworgTRxhtmlDTDxhtml-strictdtd>
DECLARE titles_cursor CURSOR FOR select distinct E_ID from C_Employee order by E_ID ASC ;
declare @ids as varchar(1000)
OPEN titles_cursor
declare @iname as int
FETCH NEXT FROM titles_cursor INTO @iname
WHILE @@FETCH_STATUS = 0
BEGIN
   select top 10 * from c_monthattendance where
FETCH NEXT FROM titles_cursor INTO @iname
END
CLOSE titles_cursor
deallocate titles_cursor

你可能感兴趣的:(游标)