t-sqlformatmanagement-studio-express

MSSQL 2014 Format function is not recognized


I'm using MicrosoftSQL Server 2014 and Management Studio version 12.0.4100.1 and trying to use Format function to do the following:

Format([money spent], 'C', 'en-us') as 'You Spent'

When executing that statement I get the following error:

'format' is not a recognized built-in function name.

I tried to change compatibility level as well, changing to 110 did not work by saying that Valid values of the database compatibility level are 80, 90, or 100

Is there is an alternative that I can use to achieve the same result, or I still can use Format function after changing some other settings?


Solution

  • Since FORMAT() is not supported in 2008 you have to manually format. You can try something like

    SELECT '$' + CAST(ROUND([money spent], 2) AS VARCHAR(25))