The new version(2012) of sql server makes easy to string conversion from number or date.We don't have any direct function to do this one in older versions .If we want to do this one ,then we have to use Conversion functions(CAST or CONVERT).
SELECT CAST(date AS nvarchar(100)) AS string_date from OrdersThe FORMAT string function has introduced to convert the number/date to string in Sql server 2012 .Here i have given a simple query to get the amount(It has money data type in table) in currency format.
SELECT order_ID,FORMAT(Price_Amt, 'C', 'en-us') AS 'Amount' from OrdersIn this function we have to use standard numeric formats for desired Format ..Details about standard Numeric Format Strings
2 comments:
Great information about converting number to string in sql server.
Thanks for your valueble comments
Post a Comment