-- Run this from the current ISQL/W window
DECLARE @Percent int, @TotalRows int, @Skipped int, @CurrentRow int
-- procedure body
SELECT @CurrentRow = 0, @Skipped = 0, @TotalRows = 45
WHILE(@CurrentRow < @TotalRows)
BEGIN
        SET @CurrentRow = @CurrentRow + 1
        -- report logic
        SELECT @Percent = (@CurrentRow*100)/@TotalRows
        EXEC sp_user_counter1 @Percent

        WAITFOR DELAY '00:00:01'

        IF (@CurrentRow%2) = 0 SET @Skipped = @Skipped + 1
        EXEC sp_user_counter2 @Skipped
END
GO

-- Run this from another ISQL/W window
select * from master..sysperfinfo
where object_name = 'SQLServer:User Settable' and
        patindex('User counter [12]', cast(instance_name as varchar)) > 0
This page was last updated on May 01, 2006 04:28 PM.