What happens if you have digits to right of decimal?
declare @value3 integer
@value3 = 197.81
SELECT RIGHT('000'+CAST(CAST(@value3 AS INT) AS VARCHAR(7)),7)
gives value 000197
any help on this would be appreciated.
Do you want to keep the decimal values? If so, declare the variable as something that will do what you need, then don't cast it to Int inside the string function.
Declaring the variable as Int drops the decimal value before you even begin formatting it.
- Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
Property of The Thread
"Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon