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)
 smallint to smallint division question

Author  Topic 

chedderslam
Posting Yak Master

223 Posts

Posted - 2009-07-02 : 13:37:52
update table
set table.value = ( table.value / 12 )

datatype is smallint. Will it round down to nearest whole number automatically or do I need to apply some function?

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-07-02 : 13:44:38
it will undergo truncation and gives only integer part of result
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-07-02 : 13:53:00
see this also

http://sqlblogcasts.com/blogs/madhivanan/archive/2008/01/16/beware-of-implicit-conversions.aspx
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-07-02 : 13:57:39
also try this

update table
set table.value =round(( table.value * 1.0 / 12 ),0)
Go to Top of Page
   

- Advertisement -