SELECT * FROM aspnet_Roles
GO

DECLARE @role varchar(50)
DECLARE CusCursor CURSOR FOR select RoleName from aspnet_Roles
OPEN CusCursor
FETCH NEXT FROM CusCursor INTO @role
WHILE (@@FETCH_STATUS = 0)
BEGIN
SELECT @role
--这里写SQL语句
FETCH NEXT FROM CusCursor INTO @role
END
CLOSE CusCursor
DEALLOCATE CusCursor

如图所示:

游标使用的简单示例_SQL