How can I format a zero?

  • Hi,

    I'm trying to return 0.00 from a procedure which uses decimals when the value is zero. However, the following code returns .00 - does anyone know a good way of doing this?

    declare @mydec as decimal (10,2)

    set @mydec = 0

    select @mydec

    Thanks in advance

    Paul Ibison PhD, MCSD

    email: Paul.Ibison@btinternet.com


    Paul Ibison
    Paul.Ibison@replicationanswers.com

  • Reply to my own question - just in case someone else had a similar issue.

    Solution is use select cast(@mydec as varchar(12)) as MyField, and 0.00 mysteriously appears.

    Paul Ibison PhD, MCSD

    email: Paul.Ibison@btinternet.com


    Paul Ibison
    Paul.Ibison@replicationanswers.com

  • Thanks for posting your solution Paul!

    cast is real handy for moving one datatype to another.

    Wes

Viewing 3 posts - 1 through 2 (of 2 total)

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