March 30, 2006 at 4:11 pm
I’m looking to query a integer value and display it as a formatted string (varchar) with commas. For instance the value stored in the database is 12345, I would like to query this value as a formatted string like 12,345.
I’ve see this asked on other threads, but I don’t see a good answer.
I expect some one will say it is not the job of the server to do this. Well, I am in a situation the returned value is expected to be a string.
March 30, 2006 at 4:37 pm
This seems to work:
select convert(varchar,cast(12345 as money),1)
March 31, 2006 at 9:16 am
To drop the decimal point and what follows.
select
left(convert(varchar,cast(12345 as money),1),len(convert(varchar,cast(12345 as money),1))-3)
And yes, someone will tell you it's not the servers job. Doesn't change the fact that it's your job....
Mike
April 1, 2006 at 7:40 pm
Finally... the voice of reason...
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply