游标的定义供参考
游标定义:
1
DECLARE @SalaryItemID INT
2
DECLARE SalaryItem_Cursor Cursor
3
FOR
4
SELECT SalaryItemID FROM Payroll.SalaryItem WHERE CompanyID=@CompanyID ORDER BY SalaryItemID
5
Open SalaryItem_Cursor
6
Fetch NEXT FROM SalaryItem_Cursor INTO @SalaryItemID
7
While (@@FETCH_STATUS <> -1)
8
BEGIN
9![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
10
---执行语句
11![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
12
Fetch NEXT FROM SalaryItem_Cursor INTO @SalaryItemID
13
END
14
CLOSE SalaryItem_Cursor
15
DEALLOCATE SalaryItem_Cursor
16![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
2
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
3
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
4
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
5
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
6
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
7
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
8
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
9
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
10
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
11
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
12
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
13
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
14
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
15
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
16
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)