Reputation: 18679
I have this data as varchar '00072330'. How do I convert it to a decimal that looks like '723.30' in SQL Server 2008?
Upvotes: 3
Views: 41705
Reputation: 332571
This:
SELECT CAST('00072330' AS INT)/100.0
...will give you:
723.300000
The .0 is important, otherwise SQL Server will perform integer math.
Upvotes: 3
Reputation: 57946
Try this:
declare @data as varchar(8)
set @data = '00072330'
print cast(@data as decimal) / 100
Upvotes: 9