CLR number format

  • Hi...I have db with Cyrillic_General_CI_AS collation...and I have assemblie doing some calculations...problem is that I need "." instead of "," in numbers.

    SqlContext.Pipe.Send((100 / 3).ToString("N2"))

    SqlContext.Pipe.Send(FormatNumber(100 / 3,,,,))

    are not showing correct values

    please help...I have tried to change cultureinfo...but still no results..

  • Why are you formatting the numbers in the database? The numbers should be formatted in the presentation layer.

    Adi

    --------------------------------------------------------------
    To know how to ask questions and increase the chances of getting asnwers:
    http://www.sqlservercentral.com/articles/Best+Practices/61537/

    For better answers on performance questions, click on the following...
    http://www.sqlservercentral.com/articles/SQLServerCentral/66909/

  • that is correct, but....

    I have some calculations in CLR...lets say a have to present on web page some data like miles per day...I have 30 days period and 100 miles per agent...

    100/3=3.3333333

    because of SQL server collation I get 3,333333

    when I try to output data from CLR using FormatNumber(100/3,,) in VB.NET I get 3,3333.00 and that is not correct

  • If you use a numeric data numeric data type (by numeric, I mean any data type that can only store numbers such as int, decimal, money etc’) then the server doesn’t store the number with any coma or dot to separate every 3 numbers. Most chances are that you have a bug in the code.

    Adi

    --------------------------------------------------------------
    To know how to ask questions and increase the chances of getting asnwers:
    http://www.sqlservercentral.com/articles/Best+Practices/61537/

    For better answers on performance questions, click on the following...
    http://www.sqlservercentral.com/articles/SQLServerCentral/66909/

  • my CLR assemblie has output like this:

    agentID, agent miles per day

    for miles I have created table in vb.net where I'm doing all calculations with columns agentId(int) and MPD(decimal)

    in CLR that table is using, I'm gust guessing, local regional settings, that has "," instead of "."...later on when I use

    for each DR as datarow in Dtable

    SetSqlString(dr(0),"miles " + formatnumer(dr(1) ,,,))

    next

    I get

    miles 2,34.00

Viewing 5 posts - 1 through 4 (of 4 total)

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