conversion problem with number and characters

  • Here is the code that I am using, I am getting an error after the last line indicating that it cannot convert nvarchar to float, even though it appears as if I am doing an explicit conversion just above that. Any ideas why this isn't working? Thanks,

    --------------------------------

    declare @advTotal float

    declare @advwithoutvoid float

    declare @body1 nvarchar (1000)

    set @advTotal = (SELECT Sum(Inves)+Sum(Trust)+Sum(Payme)+Sum(Defin) FROM gtgtable)

    set @advwithoutvoid = (SELECT Sum(Inves)+Sum(Trust)+Sum(Payme)+Sum(Defin) FROM gtgtable where processclassid =4)

    set @advTotal = convert(char(1000),@advtotal)

    set @body1 = 'Advantage File Total'+char(9)+char(9)+char(9)+@advTotal+char(13)

    ----------------------------------

  • your last line would work if it read like so:

    set @body1 = 'Advantage File Total'+char(9)+char(9)+char(9)+convert(char(1000),@advtotal)

    +char(13)

  • Thanks so much for the help, it worked perfectly.

    Out of curiousity, why doesn't it work when you do the convert just above it, as a separate action?

  • good to hear.

    regarding the question, the var is declared as a float and remains that way in your procedure. so, the statement above had no real affect on the variable.

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

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