How to change a Float into a VARCHAR(500)

Sarah George 1 Reputation point
2022-09-22T15:34:56.28+00:00

In the design I want to link AgreementId from AgIDTenRef box to 2ndyrletonlyfee on the 'RenewalsCompleted' box (as shown) but when I do either of these it errors: CAST(v_statActiveCount_mis.2ndyrletonlyfee AS FLOAT) AS TEST CAST(AgIDTenRef.AgreementId AS VARCHAR) AS TEST

One of the errors is 'Error converting data type from varchar to float'

2ndyrletonlyfee = VARCHAR Agreement Id = FLOAT

PLEASE HELP!

Thanks Sarah243898-float-to-nvarchar500.png

Developer technologies | Transact-SQL
SQL Server | Other
{count} votes

1 answer

Sort by: Most helpful
  1. Erland Sommarskog 121.9K Reputation points MVP Volunteer Moderator
    2022-09-22T21:25:15.973+00:00

    I will need to say that this sounds dubious. Something called ID which is a float? Float is good for scientific values can have very high or low ranges, but it is an approximate number, so it is not good for an id:

    And comparing that to a varchar(500). As Viorel says, this will be problematic.

    I think you need to go back and review the database design. I have a feeling that you went wrong at some point earlier before you came to this brick wall.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.