0

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?

gene
  • 2,098
  • 7
  • 40
  • 98
  • What is the data type of [money spent] – Fuzzy Jan 14 '16 at 20:06
  • Also are you sure the database you are connecting to is 2014? Try `select @@version` and what do you see – SQLChao Jan 14 '16 at 20:07
  • data type of [money spent] is `money` – gene Jan 14 '16 at 20:24
  • @SQLChao, Oh, actually, database I'm connecting to is Microsoft SQL Server 2008 (SP1). That is the problem. Format is not recognized. I looked in the "Help" menu and saw some version numbers for management studio and SQL Server, but actual database version is 2008 – gene Jan 14 '16 at 20:26
  • You'll have to write some TSQL to manually format `money spent` – SQLChao Jan 14 '16 at 20:49

1 Answers1

0

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))
SQLChao
  • 7,709
  • 1
  • 17
  • 32