Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Float/Decimal/Casting Question

Status
Not open for further replies.

Veejc

Programmer
Sep 24, 2002
52
US
I am trying to do this:

declare @percent int, @convertedpercent int

set @percent = 5
select @percent
select cast(@percent/100 as decimal(5,2) )

(it's part of a bigger SP, but that's essentially where my problem is lying)

All I am looking for is the result to read accurately

5/100 = .05

when I execute this in QA, I get 0.0

I also tried:
set @convertedpercent = @percent/100

Don't know what I'm missing, not really all that familiar with the nuances of SQL Server

Thanks in advance for any help
 
Any time you divide an int by an int, you get a whole number anser. Change your original declaration of the @percent variable to decimal.

Questions about posting. See faq183-874
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top