I have the following SQL statement:
select pc.*,au.UserName from ProspectsInCampaigns pc
inner join prospects p on p.id=pc.prospectid
inner join aspnet_Users au on STR(au.UserId)=pc.updatedby
WHERE p.id=1225982
The problem is, that the updatedby field in ProspectsInCampaigns contains either an empty string, or a string that is indeed a UUID.
In the above case I get the error:
Operand type clash: uniqueidentifier
is incompatible with float
How can I prevent that from happening?
Don’t compare the
UUIDto afloat. Why are you doing that anyways?You can consult this handy chart to know what conversions are allowed. If you can’t convert two datatypes to each other, you can’t compare them directly.
Hypothetically you could convert both to a string type like
varcharbut since it’s impossible to have aUUIDmatch anything that can be afloatthere’s no point.Edit:
More specifically, it looks like
Useridis aUUIDand theSTR()function is specifically for convertingfloatdata to a string datatype.Why are you trying to convert au.UserID anyway? If you have a UUID, compare it to the other UUID directly.