Adding commas to numeric values

  • No fight = I win (didn't you read the article)??

    Yes it's weekend, we have a Holiday on the 24th and another on the 1st. Then it's 2 weeks vacation starting the 16th .

    I'm not huge, neither am I a fan. I just respect his dedication to sql (he's on the ainsi sql standard boards for god's sake... how many of us will go that far in sql?????????). I totally agree that he's too harsh in his comments, that's why I try to tone 'em down when I can.

  • yes - I read the article - (there would never have been a fight 'cos I'm too nice!) <;-)

    I don't give a %$#& if he's GOD himself - yes, I am aware of his accomplishments & fully acknowledge his brilliance - however, in my book (the non-sql one) - his criticism of others is extremely insulting - I know that if I ever worked with someone like him I would learn nothing and would walk in fear all the time...maybe I should just develop a thick skin....







    **ASCII stupid question, get a stupid ANSI !!!**

  • Or good claws .

  • Not bad : 20 post, only one message from the starter of the thread .

  • I think I'm not explaining what I need to do. I do not what to store the value with the comma, I just need the results to show the comma. For example, I would like to write something like a convert or cast statement within the query that would then format the results as seem in the results tab of query analyzer or within the text file (if I exported the query results). Again, I may be misspeaking, but I'm looking to do something like a CONVERT(CHAR(10), datetimevalue, 101); but with a numeric field- formatting to include a comma in the results output (not within the server).

  • Again, this is a task that the APPLICATION should be doing, the server can do it but its work is to fetch data and send the results as fast as possible... Also most reporting services have built-in tools to do stuff like that.

    What will be done with that data in the application?

  • I understand you points/concerns. I was just looking for a quick option to format ad-hoc queries for a set of users, versus setting something up in another application. I had hoped that there may be a built in function within SQL Server that I could make use of to do this. The users are going to be asking a number of ad-hoc questions that I will not know in advance, and I was wanted a way to format large numbers in the text output of the results tab so that it would be easier for them to read. There really is no application data per se. These are large tables that I need to query and show results. Thank you anyway.

  • here's a link that discusses the exact same request - you might find your solution here...though there's nothing quick and easy!

    http://www.sqlservercentral.com/forums/shwmessage.aspx?forumid=8&messageid=151824







    **ASCII stupid question, get a stupid ANSI !!!**

  • If it's only you who'll be doing the sql-stuff, and you want quick formatting, there is always this "office"-thing.

    Query sqlserver using e.g. excel and you'll have all the fancy formatting-stuff excel offers      

    Don't promote this, because unwize usage of sql could have it's impace to your sqlserver 

    Johan

    Learn to play, play to learn !

    Dont drive faster than your guardian angel can fly ...
    but keeping both feet on the ground wont get you anywhere :w00t:

    - How to post Performance Problems
    - How to post data/code to get the best help[/url]

    - How to prevent a sore throat after hours of presenting ppt

    press F1 for solution, press shift+F1 for urgent solution 😀

    Need a bit of Powershell? How about this

    Who am I ? Sometimes this is me but most of the time this is me

  • SELECT CONVERT(varchar,CAST(123456.9901 AS money),1)

    Andy

  • Andy - I spent so much time looking at that money datatype and still couldn't come up with this....GREAT!







    **ASCII stupid question, get a stupid ANSI !!!**

  • Andy, thanks, that was what I was looking for. It retains a decimal, but having the commas will help with this one time need. Appreciate it.

  • declare @N decimal(19,2)

    set @N = 654878766456412

    select left(convert(varchar,convert(money,@N),1),len(convert(varchar,convert(money,@N),1)) - 3)

  • You know I have the same problem. would like to format the returned result as a string formated like 10,000. I would agree that the value should be stored as a number, but I'm not storing it, I am querying it and would like to display it with commas as that is how it is expected to be displayed.

Viewing 14 posts - 16 through 28 (of 28 total)

You must be logged in to reply to this topic. Login to reply