error while casting a column name

  • SetFormattedValue =CASE

    When rg.ReferredFieldType='NUM'

    Then CAST(#PointedMslValues.Value AS NUMERIC(18,cAST(rg.ReferredDecimalPoints) )

    more cases .

    END

    I am generating a dynamic query which is giving error actually it requires integer value while casting not a column name

  • Can you able to say what is type of FormattedValue column.

    FormattedValue column strict to type so you can not assign other type except type of FormattedValue column.

    Thanks,

    Nishant

    ID:nishantcomp2512

  • ALI100 (2/6/2013)


    SetFormattedValue =CASE

    When rg.ReferredFieldType='NUM'

    Then CAST(#PointedMslValues.Value AS NUMERIC(18,cAST(rg.ReferredDecimalPoints) )

    more cases .

    END

    I am generating a dynamic query which is giving error actually it requires integer value while casting not a column name

    If you are creating a dynmaic query then try the output be like NUMERIC (18,9) ..so use concatenation of strings..

    ~ demonfox
    ___________________________________________________________________
    Wondering what I would do next , when I am done with this one :ermm:

  • ALI100 (2/6/2013)


    SetFormattedValue =CASE

    When rg.ReferredFieldType='NUM'

    Then CAST(#PointedMslValues.Value AS NUMERIC(18,cAST(rg.ReferredDecimalPoints) )

    more cases .

    END

    I am generating a dynamic query which is giving error actually it requires integer value while casting not a column name

    CAST(rg.ReferredDecimalPoints AS datatype)

    However, it's unlikely to be as simple as this because it will have to be stringified to work. Can you post the whole query?

    “Write the query the simplest way. If through testing it becomes clear that the performance is inadequate, consider alternative query forms.” - Gail Shaw

    For fast, accurate and documented assistance in answering your questions, please read this article.
    Understanding and using APPLY, (I) and (II) Paul White
    Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden

  • FormattedValue VARCHAR(MAX)

  • Thanks Grasshopper for quick reply.

    you can not use cAST(rg.ReferredDecimalPoints) to add decimal point to numeric data type.you can not use variable inside numeric bracket.you have to pass static value.

    you can accomplish this by Substring function in sql.select only few char after decimal point from varchar data.

    i thinks to pick only few char after decimal point is easy that casting to impossible numeric type as we want data should be in varchar.

    Nishant

    ID:nishantcomp2512

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

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