• I'm not sure what "0-0" means.  If your demonator is a variable or a computation involving variables than you can then you can do somthing like this:

    delcare @res int (I assume you know that this will truncate the decimal portion of your result)

    if @queryvar1 - @queryvar2 <> 0 begin

      select @res = 5000 / @queryvar1 - queryvar2

    else begin

      select @res = 0

    end