• There is no need to include upper() in the where clause. TSQL is not case sensitive. Since the minumum allowable amount of space may vary between systems it makes more sense to me to have parameters for the allowable space by drive than to hardcode them. The original script was overly generous in declaring space for its variables. One example, since @convertedC is being set to convert(varchar(20),@c) then @convertedC does not need to be any bigger than 20. And @string would never get any near as long as 8000 characters.

    Revised code:

    alter procedure harddisk_check_space

    @MinOkC int = 20,

    @MinOkNotC int = 3

    as

    begin

    declare @mytable table (drive varchar(10),sp int)

    declare @C int

    declare @notc int

    insert into @mytable exec master.dbo.xp_fixeddrives

    select @C=sp from @mytable

    where drive='C'

    select @notc=sum(sp) from @mytable

    where drive<>'C'

    set @C=@c/1000

    set @notc=@notc/1000

    if(@c < @MinOkC or @notc < @MinOkNotC)

    begin

    declare @string varchar(120)

    declare @convertedC varchar(20)

    declare @convertedNotC varchar(20)

    set @convertedC=convert(varchar(20),@c)

    set @convertedNotC=convert(varchar(20),@notc)

    set @string='there is not enough space left on the server, '+@convertedC+' GB left on C: and '+@convertedNotC+' GB left on the other drives'

    raiserror(@string,16,1) with log

    -- print (@string)

    end

    end