IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[RoundBanker]') AND xtype in (N'FN', N'IF', N'TF'))
DROP FUNCTION [dbo].[RoundBanker]
GO

IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[RoundBanker]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
DROP PROCEDURE RoundBanker
GO

CREATE FUNCTION [dbo].[RoundBanker]  
(@x money, @DecimalPlaces tinyint)
    RETURNS money AS
    BEGIN

    set @x = @x * power(10, @DecimalPlaces)

    return
    case when @x = floor(@x) then @x
    else
    case sign(ceiling(@x) - 2*@x + floor(@x))
    when 1 then floor(@x)
    when -1 then ceiling(@x)
    else 2*round(@x/2,0) end
    end / power(10, @DecimalPlaces)
    END
GO