Professional Web Applications Themes

CAST anomaly - Microsoft SQL / MS SQL Server

Alex, The default conversion of money types to character types with CAST or CONVERT displays two decimal places. The default display of a money type to the Query yzer window as a string, however, is simply a function of the tool, and doesn't invoke CAST or CONVERT. It happens to show more decimal places. If you want to display a money type with 4 decimal places, you have two choices. You can use CONVERT with format specifier 2, or you can use STR (which implicitly converts to float before converting to characters, which could cause some rounding issues): SELECT ABC, ...

  1. #1

    Default Re: CAST anomaly

    Alex,

    The default conversion of money types to character types
    with CAST or CONVERT displays two decimal places. The
    default display of a money type to the Query yzer window
    as a string, however, is simply a function of the tool, and doesn't
    invoke CAST or CONVERT. It happens to show more decimal
    places.

    If you want to display a money type with 4 decimal places, you
    have two choices. You can use CONVERT with format
    specifier 2, or you can use STR (which implicitly converts to
    float before converting to characters, which could cause some
    rounding issues):

    SELECT ABC, CONVERT(VARCHAR(254),ABC,2)
    SELECT str(ABC,20,4)

    -- Steve Kass
    -- Drew University
    -- 094A245B-C135-414D-BA79-DEBD98939207



    "Alex Clark" <spamtin.net> wrote in message
    news:phx.gbl... 
    can 


    Steve Guest

  2. #2

    Default Re: CAST anomaly

    Bob Barrows (com) writes: 

    I have not checked what applies for the money datatypes, but I know that
    for dates, SQL Server does not look at Regional Settings. I would expect
    SQL Server to look at the language settings to infer the format.


    --
    Erland Sommarskog, SQL Server MVP, se

    Books Online for SQL Server SP3 at
    http://www.microsoft.com/sql/techinfo/productdoc/2000/books.asp
    Erland Guest

  3. #3

    Default Re: CAST anomaly

    Thankyou Bob and Steve, this worked perfectly!


    Alex Guest

  4. #4

    Default Re: CAST anomaly

    Erland Sommarskog wrote: 
    >
    > I have not checked what applies for the money datatypes, but I know
    > that for dates, SQL Server does not look at Regional Settings. I
    > would expect SQL Server to look at the language settings to infer the
    > format.[/ref]

    Yes, you're right of course.


    Bob Guest

Similar Threads

  1. Send For Review anomaly
    By saanich in forum Macromedia Contribute General Discussion
    Replies: 2
    Last Post: July 26th, 06:22 PM
  2. Save for Web Anomaly
    By Kimberly_Malaryk@adobeforums.com in forum Adobe Illustrator Macintosh
    Replies: 0
    Last Post: April 28th, 09:03 PM
  3. onstat -d anomaly
    By Bill Hamilton in forum Informix
    Replies: 0
    Last Post: October 31st, 02:25 PM
  4. Rendering anomaly
    By Dave Mennenoh in forum Macromedia Director 3D
    Replies: 0
    Last Post: October 8th, 06:16 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139