游标示例

< 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
posted @ 2009-10-17 16:22  netcorner  阅读(144)  评论(0编辑  收藏  举报