Select number with comma separated like 1,23,45,678 in SQL RRS feed

  • Question

  • User1152553138 posted

    How to select value with comma separated like 1,23,45,678

    Tuesday, April 17, 2018 4:45 AM

All replies

  • User1497757439 posted

    Try this. NOTE : It will work with SQL Server 2012, or later

    SELECT Format(12345678, '##,##0')

    Tuesday, April 17, 2018 5:03 AM
  • User1152553138 posted

    Thanks for the reply ...

    the above is separating the value by default for 3 digit ... But i need like this 1,23,45,678

    Tuesday, April 17, 2018 9:39 AM
  • User753101303 posted


    Still unclear. Do you meant you want to have a value IN (1,23,45,678) where clause ???

    Or you really mean you have a single numeric column with 12345678 and you want to format this single numeric value with multiple commas ???  If this is quite usual for your culture, what is your culture ?

    (IMHO formatting is best done on the web server side rather than directly as part of a SQL statement)

    Tuesday, April 17, 2018 9:44 AM
  • User1152553138 posted

    Yes, Format this single numeric value with multiple commas and our Culture in INDIA Rupees ...

    How to do in webservice any eaxmaple ???

    Tuesday, April 17, 2018 12:13 PM
  • User1497757439 posted

    Please try this 
    SELECT FORMAT(12345678,'C','en-IN')

    Tuesday, April 17, 2018 12:37 PM
  • User753101303 posted

    I tried SELECT FORMAT(12345678,'n0','hi-in') which shows 1,23,45,678

    It just uses .NET Framework formatting strings and culture settings. You can use https://msdn.microsoft.com/en-us/library/bz9tc508.aspx to configure the culture you want for your ASP.NET web app and then it should be just fine.

    The benefit is that then if you tell to use n0 you could support multiple cultures and it will just show the correct formatted string depending on the culture currently in use (compared with using some kind of hardcoded format).

    Tuesday, April 17, 2018 12:45 PM