Brettb.Com
  HOME | ABOUT ME | BIOTECHNOLOGY | ARTICLES | GALLERY | CONTACT
Search: Go
TECHNICAL ARTICLES
 ASP
 ASP.NET
 JavaScript
 Transact SQL
 Other Articles
 Software Reviews

PHOTO GALLERIES
 Canon EOS 300D Samples
 Akihabara Maids!
 More Galleries...

TRAVEL LOG
 2009: China
 2008: Tokyo
 2007: Tokyo
 2006: Hong Kong
 2005: New York City

MORE STUFF
 Search Engine Optimisation
 Build an ASP Search Engine
 My Tropical Fishtank
 Autoglass
 SQL Month Name
 SQL Get Date Today
 SQL Year Month
 Other New Stuff...

POPULAR STUFF
 Regular Expressions
 Index Server & ASP
 JavaScript Ad Rotator

Home > Articles > Transact SQL Programming Articles

Using the Transact SQL Round Statement

The Transact SQL Round mathematical function can be used to round a number to a specified number of decimal places or to truncate a number. For example, to round the variable angle to two decimal places, the following Transact SQL can be used:

select round(angle, 2)

Note that specifying a negative figure for the number of decimal places will result in the value to the left of the decimal point being rounded, so the following SQL statement will return a value of 900:

select round(903.972, -2)

Truncating Numbers

By including an integer greater than 0 as the third argument of the round function, it is possible to truncate numbers. The following SQL statement returns 903.000:

select round(903.972, 0, 1)

Useful Links

  • The SQL Documentation Tool builds technical documentation for Microsoft SQL Server databases. A free trial version is available for download.

  Site Map | Privacy Policy

All content is 1995 - 2012