views:

223

answers:

1

Here's my simplified table (SQL Server 2005):

table1: col1 int, col2 int, col3 cast(col1/col2 as int) [computed column]

for some reason the above doesn't work. i just want to save a WHOLE part of col1/col2, how do i do that?

example: col1 = 5, col2 = 3 ... col3 should be 1
+2  A: 

One option would be to use the floor function:

FLOOR(col1/col2)

or

CONVERT(int, FLOOR(col1/col2)) -- Might be overkill

ChrisHDog
what result are you getting when you do col1/col2 ?
ChrisHDog
nevermind ... i got the columns mixed up ... floor() works just fine
roman m