replace function

  • hi,

    i am using replace function.

    giving me error like 'Error converting data type nvarchar to float'

    reportheading1 is nvarchar(72)

    select ReportHeading1 From vPortfolioBase

    Where PortfolioBaseCode = Replace(@Portfolios,'@','') as reportheading1

    any help?

  • Either column "PortfolioBaseCode" is datatype Float, or variable "@Portfolios" is. Can't tell which one from your post, but it's one or both.

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

  • they both are nvarchar

  • Then the error is somewhere else in your code. Post the right part.

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

  • nope.if i remove this line,it works fine

  • GSquared (4/25/2012)


    Then the error is somewhere else in your code. Post the right part.

    Gus, walk away. You will never get a full answer to any of your questions.

  • Then there's something else wrong.

    If you're getting that error message, some piece of your query is trying to convert a string (NVarchar) to a floating point value, and it's incompatible. You don't get that error unless that's what's going on.

    Is that the whole query? Or is it part of something else?

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

  • These errors are conversion errors. Somewhere your data contains a value that is not compatible with the float type.

    I don't see anything in that code that would cause it, so I suspect you are missing something else in the code.

  • Lynn Pettis (4/25/2012)


    GSquared (4/25/2012)


    Then the error is somewhere else in your code. Post the right part.

    Gus, walk away. You will never get a full answer to any of your questions.

    I know. Not worried about it.

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

  • Does anyone see anything wrong with this where clause?

    Where PortfolioBaseCode = Replace(@Portfolios,'@','') as reportheading1

  • Lynn Pettis (4/25/2012)


    Does anyone see anything wrong with this where clause?

    Where PortfolioBaseCode = Replace(@Portfolios,'@','') as reportheading1

    "as" then column alias in a Where clause.

    Which won't parse.

    Which means it's not the actual code (since it would get a different error).

    Which means the error is coming from something other than what was posted.

    Which means ...

    That's why I'm not bothering asking for the code. Just pointing out that the problem is caused by a conversion error and how to look for one.

    You may note I'm telling him what's wrong, not asking him to clarify. I know that won't happen, from his posting history. Either he'll work with what I post, or he won't. Not my problem either way. His problem to deal with.

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

  • GSquared (4/25/2012)


    Lynn Pettis (4/25/2012)


    Does anyone see anything wrong with this where clause?

    Where PortfolioBaseCode = Replace(@Portfolios,'@','') as reportheading1

    "as" then column alias in a Where clause.

    Which won't parse.

    Which means it's not the actual code (since it would get a different error).

    Which means the error is coming from something other than what was posted.

    Which means ...

    That's why I'm not bothering asking for the code. Just pointing out that the problem is caused by a conversion error and how to look for one.

    You may note I'm telling him what's wrong, not asking him to clarify. I know that won't happen, from his posting history. Either he'll work with what I post, or he won't. Not my problem either way. His problem to deal with.

    But he also said

    riya_dave (4/25/2012)


    nope.if i remove this line,it works fine

    So, if he takes out this code:

    select ReportHeading1 From vPortfolioBase

    Where PortfolioBaseCode = Replace(@Portfolios,'@','') as reportheading1

    No error.

  • thanks guys,got the answer,

  • anybody here ssrs expert??????????

  • riya_dave (4/25/2012)


    anybody here ssrs expert??????????

    im sure there are some and if you post in the SSRS section of the boards and post all the information we request you may get better results.


    For faster help in answering any problems Please read How to post data/code on a forum to get the best help - Jeff Moden[/url] for the best way to ask your question.

    For performance Issues see how we like them posted here: How to Post Performance Problems - Gail Shaw[/url]

    Need to Split some strings? Jeff Moden's DelimitedSplit8K[/url]
    Jeff Moden's Cross tab and Pivots Part 1[/url]
    Jeff Moden's Cross tab and Pivots Part 2[/url]

Viewing 15 posts - 1 through 15 (of 23 total)

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