I have this SQL:
select *
from TableA A left join TableB B
on A.ID = B.ID
where A.Column = :H
order by case when :H <> :H
then NumericCol --decimal(7) TableA
else CharCol end ; --char(6) TableA

It runs fine as long as the result set only includes numbers for CharCol,
but it fails with a conversion error if CharCol contains letters. I
commented out the ORDER BY and it runs. I put the ORDER BY back and it
failed again, so I know the ORDER BY is the problem. It's casting CharCol
to decimal(7). I tried flipping the condition in the ORDER BY, but that
didn't make a difference.

1. I'm curious why it's doing the cast.
2. Is there any relatively painless way to stop it?

Thx

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.