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.
Hello:I am writing a sql statement that is parsing data to be output to a file. I have a money field that I need to pad with 0's for a length of 5. For example:3.75 needs to become 00375. Any good ideas on the easiest way to accomplish this.Thanks, Al
SamC
White Water Yakist
3467 Posts
Posted - 2003-07-11 : 11:46:19
'00000' + CAST(moneyfield AS VARCHAR)gives'000003.75'But you want only 5 digits so wrap it in RIGHT ('00000' + CAST(moneyfield AS VARCHAR), 5)Sam