Stupid SQL question: divide by variable

This seems like it should be so simple! I am trying to compute the number of rows in one table divided by the number of rows in another table, as follows:

DECLARE @i1 int
DECLARE @i2 int
DECLARE @d1 decimal(10,2)

SET @i1 = (SELECT COUNT(*) FROM tblLast)
SET @i2 = (SELECT COUNT(*) FROM tblUnits)
SET @d1 = ( @i1 / @i2 )

SELECT @i1
SELECT @i2
SELECT @d1

SQL Server 2005 keeps returning @d1 = 0.00. I have the feeling that I’m using a wrong data type, but Google is not showing me the way out. Any suggestions? TIA!

Declare i1 and i2 as dec(10,2) as well.


SET @d1 = ( @i1 / @i2 )

is treated as an integer division.

Marvelous, thank you!