ãã游æ æçæ¯ä¸´æ¶è¡¨æçé«
ãã临æ¶è¡¨å¦ä¸ï¼
ããSELECT EmpCo FROM Employees
ããselect identity(int,1,1) as id,* into #T from Employees --第ä¸æ¡æç´¢è¯å¥
ããdeclare @i int
ããdeclare @total int
ããdeclare @EmpCo varchar(10)
ããselect @total = count(*) from #T
ããset @i = 1
ããwhile @i <= @total
ããbegin
ããselect @EmpCo=EmpCo from #T where id = @i --第äºæ¡æç´¢è¯å¥ï¼èä¸æ¯å¾ªç¯æ§è¡çã
ããprint @EmpCo
ããset @i = @i + 1
ããend
ããdrop table #T
ãã-----------------------------------------------
ãã游æ å¦ä¸ï¼
ããDeclare @EmpCo as varchar(50)
ããDeclare @EmpCo1 as varchar(50)
ããDECLARE Employee_Cursor CURSOR FOR
ããSELECT EmpCo FROM Employees ---åªæå¨è¿æä¸æ¡æç´¢è¯å¥
ããOPEN Employee_Cursor
ããFETCH NEXT FROM Employee_Cursor INTO @EmpCo
ããWHILE @@FETCH_STATUS = 0
ããBEGIN
ããFETCH NEXT FROM Employee_Cursor INTO @EmpCo
ããprint @EmpCo
ããEND
ããCLOSE Employee_Cursor
ããDEALLOCATE Employee_Cursor
ãã临æ¶è¡¨çï¼è¦ç¨ä¸¤æ¡æç´¢è¯å¥ï¼èä¸æ¯å¾ªç¯æ§è¡çã ï¼ç¶èï¼æ¸¸æ çåªç¨ä¸æ¡æç´¢è¯å¥ï¼æ²¡æ循ç¯æ§è¡ç循ç¯è¯å¥
温馨提示:答案为网友推荐,仅供参考