Banker's Rounding in SQL Server 2000

Posted on 2004-10-18
Last Modified: 2008-01-16
How do I use Banker's Rounding in SQL Server 2000.  I tried to convert the function I found ( but was unable to make it work. Is there a built in function or a UDF someone has used in the past?


Question by:SpreadTheWord
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 32

Accepted Solution

bhess1 earned 500 total points
ID: 12343376
Mmmmm.... try this one

Create Function dbo.udf_BankerRound(@Amt as Money)
   Declare @Result Money
   Declare @Sgn smallint

   IF @Amt = Floor(@Amt)
      Set @Result = @Amt
      Set @Sgn = Sign(Ceiling(@Amt) - 2 * @Amt + Floor(@Amt))
      If @Sgn = 1
         Set @Result = Floor(@Amt)
         If @Sgn = 0
             Set @Result = 2 * Round(@amt / 2, 0)
             Set @Result = Ceiling(@Amt)

Featured Post

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
MSSQL Query for Selecting the SUM of a Specific Group 2 37
Need more granular date groupings 4 45
Sql server query 8 21
Need split for SQL data 7 50
Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question