Thank this author by sharing:
By Jesse McLain,
This function will add commas to a given number passed as a string, separating thousands, millions, etc. Rather than doing long division to figure out how many "digit groups" there are, it simply reverses the number string, adds the commas after every third digit (after the decimal place, if present), and then re-reverses the string for return.
PRINT dbo.fn_AddCommasToNumberString('20123.12') -- 20,123.12PRINT dbo.fn_AddCommasToNumberString('2012312') -- 2,012,312PRINT dbo.fn_AddCommasToNumberString('23') -- 23
Written by Jesse McLainjesse@jessemclain.comwww.jessemclain.comhttp://jessesql.blogspot.com
Ever try to print out a long VARCHAR(MAX)/NVARCHAR(MAX) string, only to find that it's truncated at ...
print every ascii value from a string
A bit of a break from the SQL Server side with this great new .NET class developed by new author Jer...
label printing, zebra s4m 200pdi, pdf, direct print
'string' = 'string___' ???
As a member of SQLServerCentral, you get free access to loads of fresh content: thousands
of articles and SQL scripts, a library of free eBooks, a weekly database news roundup,
a great Q & A platform… And it’s our huge, buzzing community of SQL Server Professionals
that makes it such a success.