Progress Bar 

Posted by Philip Leitch Sunday, August 30, 2009 10:41:33 PM
Create procedure Progress(
    @Min as float,
    @Max as float,
    @Value as float,
    @Length as int = 100)
as
/*
www.prlsoftware.com
Author: Philip Leitch
Date: 2009
Purpose: Creates a text based progress bar.
Copyright: Philip Leitch 2009
Licensing: This code may be used or modified but if the code is included in a software package attribution to me must be made.
Liability: The developer assumes all liability when using this code.
Notes:
Best used with text return.
*/
begin
    if @min > @max or @min > @value
        begin
        print 'Invalid Range.'
        return
        end
    declare @Stars as int

    set @Stars = round((((@value - @min) )/ (@max - @min) * @Length) ,0)
    print '[' + replicate('*', @Stars) + replicate ('-', @Length-@Stars) + '] ' + cast(cast(round((((@value - @min) )/ (@max - @min) * 100) ,2) as numeric(8,2)) as varchar) + '%'
    return
end


Copyright 2009 Philip Leitch