Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
I have a decimal field that I am pulling into a view. One record currently has 500 as a value. I need to change this to 000000500.0000+field name: Qty_rec
Lamprey
Master Smack Fu Yak Hacker
4614 Posts
Posted - 2014-03-20 : 12:19:26
What is "000000500.0000+" is that a string?
Vack
Aged Yak Warrior
530 Posts
Posted - 2014-03-20 : 13:01:55
Yes
Lamprey
Master Smack Fu Yak Hacker
4614 Posts
Posted - 2014-03-20 : 13:47:24
I'm not sure why you'd want to do that, as it seems like a presentation issue to me. But, if you want to, here is one way:
DECLARE @Foo DECIMAL(18,5) = 500SELECT RIGHT(REPLICATE('0', 9) + CAST(CAST(@Foo AS INTEGER) AS VARCHAR(20)), 9) + '.0000+'