Round column numbers to nearest dollar in Sql Server 2005

I need a method to Round a column's numbers to the nearest dollar in Sql Server 2005.

Any numbers with cents (123.20) the .20 breaks the table.

Thanks for your help!
dave_skyAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ThomasMcA2Commented:
In T-SQL, Round(123.20, 0) = 123.

This SQL guide is the only reference book that is on my desk. Whenever I have an SQL question, I look there first.
0
dave_skyAuthor Commented:
How would I structure that query?

The table is: tblPlumbingListBidDetail

The column name is: UnitPrice

I basically only work with the application that is attached to the database....
0
ThomasMcA2Commented:
Like this:

SELECT ROUND(UnitPrice, 0)
   FROM tblPlumbingListBidDetail

Open in new window

0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

dave_skyAuthor Commented:
It didn't work - probably because I have NULL values in the column?
0
ThomasMcA2Commented:
This version skips the null values:

SELECT ROUND(UnitPrice, 0)
   FROM tblPlumbingListBidDetail
WHERE UnitPrice IS NOT NULL

Open in new window


If you need other fields/columns besides UnitPrice, include them like this:

SELECT ROUND(UnitPrice, 0), Field1, Field2, Field3
   FROM tblPlumbingListBidDetail
WHERE UnitPrice IS NOT NULL

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
PortletPaulfreelancerCommented:
You can use ISNULL or COALESCE to provide zero instead of null, like this:

SELECT ROUND(ISNULL(UnitPrice,0), 0), Field1, Field2, Field3
   FROM tblPlumbingListBidDetail

SELECT COALESCE(ISNULL(UnitPrice,0), 0), Field1, Field2, Field3
   FROM tblPlumbingListBidDetail

Open in new window

0
dave_skyAuthor Commented:
Thanks!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server 2005

From novice to tech pro — start learning today.