Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Using Round and Cast

Author  Topic 

snufse
Constraint Violating Yak Guru

469 Posts

Posted - 2011-03-29 : 15:44:12
I am trying to divide an integer by 42 (going from gallon to barrels) and then round to nearest hundreds.

Select round(cast((bp.gross_quantity as dec(15.3))/ 42), 3) as gross_qty,  


Getting syntax error.

Seventhnight
Master Smack Fu Yak Hacker

2878 Posts

Posted - 2011-03-29 : 15:52:27
[code]
Declare @x decimal(15,3)

Set @x = 154

Select round(cast (@x as dec(15,3))/ 42 , 3) as gross_qty
--Select round(cast((@x as dec(15.3))/ 42), 3) as gross_qty
[/code]

Corey

snSQL on previous signature "...Oh and by the way Seventhnight, your signature is so wrong! On so many levels, morally, gramatically and there is a typo!"
Go to Top of Page
   

- Advertisement -