• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Another MSSQL Question

GotIssues

Golden Member
Ok, another question from the MSSQL newb. I'm just getting my feet wet with the language, and have a major project that involves it, time is becoming an issue for me 🙁. I know of no better place to go, so please bare with me 😉

Ok, here is the dilemma. Taking a datatype for money in the format DDDDDDD.CC and I need it to convert to DDDDDDDCC, no decimal point and leading zeros where applicable.

Thanks for the help!
 
i dont think theres a built in way of doing this, this shoudl work for most cases:

select right(replicate('0',11) + replace(convert(nvarchar,<moneycol>),'.',''),9)

will pad left with 0's, remove the . and and return 9 right digits
 
SELECT Replicate('0', 9-len(Cast(MoneyField*100 As Int))) + Cast(Cast(Moneyfield*100 As int) As varchar(9))
 
Back
Top