ISNUMERIC logic stopped working


In a stored procedure we have a query that has worked in the past but no longer does on after we upgraded servers. The new server is SS2016.  It still works on our older 2012SQL Server.  Any type of options / settings that may have been that jump out at you? Or any reason at all whey we are suddenly encountering this.

Older version:

        AND ISNUMERIC(drug.GCN_SEQNO) > 0

Note: the data  from g.GCN_SEQNO is all numeric. The data in the drug.GCN_SEQNO is a char field because it has one value = 'UNKNOWN'. The rest of the data is numeric format.

When we changed to a CASE statement or Try_cast, it works fine. So we solved for it, but just not sure why its not an issue.
Updated versionL

WHERE g.GCN_SEQNO = try_cast(drug.GCN_SEQNO as numeric(28,0))
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Mark WillsTopic AdvisorCommented:
Unfortunately, comparing that way wont work

I believe the database engine looks at predicates individually if part of an index, so would be looking at the '=' and is pretty pedantic about char v number

As you have discovered, you can do
WHERE g.GCN_SEQNO = try_cast(drug.GCN_SEQNO as numeric(28,0))

Open in new window

Scott PletcherSenior DBACommented:
SQL can execute WHERE conditions in any order.  In 2012, it seems that SQL was always doing the ISNUMERIC() first, which makes sense logically as well.  But 2016 may not set the same priority for that.  Note that if SQL tries the = condition first, and the drug. column is not valid, you would get a conversion error.
Mark WillsTopic AdvisorCommented:
I have been doing a bit of digging, and struggling to find any precedence.

If you were to grab the execution plan and analyse the plan I am pretty sure you will find the "=" being evaluated before the ISNUMERIC

So, execution plans have probably changed since upgrade. Have there been any structural changes to tables ? reindexing ?

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
jvoconnellAuthor Commented:
Thank you all for the input.

Comparing execution plans did help. After investigation it looks like changes to the object was made without all of the necessary communication. We sincerely appreciate the effort. Thank you!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server

From novice to tech pro — start learning today.