0

Is there an option to create separators in sql query?

EXECUTE ('
Select 
A 
from dbo.Table') AT BAZ_PROD

   A    |
---------
92759.4 |

I want to see: 92 759.4 instead of 92759.4

i tried

EXECUTE ('
Select 
FORMAT(A, ''###,###,###.##'') AS A
from dbo.Table') AT BAZ_PROD

and have error:

The OLE DB provider "OraOLEDB.Oracle" for the linked server "BAZ_PROD" returned the message "ORA-00904:" FORMAT ": invalid ID".

Falcon
  • 59
  • 6
  • This sort of thing should be done in your presentation layer. So if you are exporting to excel or showing it in tableau you would format it there. – Bee_Riii Feb 12 '21 at 08:10
  • Your error is Oracle? But you have tagged SQL Server... please ensure your tags are correct. – Dale K Feb 12 '21 at 10:28

2 Answers2

1

You can use TO_CHAR function, you can find some good example in https://www.techonthenet.com/oracle/functions/to_char.php

for formatted numbers also you can look at this answer.

Levent Üncü
  • 325
  • 2
  • 10
1

in SQL Server you must use the FORMAT function to do so.

SELECT FORMAT(92759.4, '00 000.00')

The remaining probleme will be the leading 0

But, because this is a cosmectic question, you must not do that at the RDBMS level, but, instaed, at the application level.

SQLpro
  • 3,994
  • 1
  • 6
  • 14