SQL Error - expecting integer but finding nvarchar

Problem with Query - help with diagnosing error in sql.
Sql management studio provides me with an error message when i run a query.  If some one knows what the problem is... rogue data in a column that shouldnt be there... GREAT!
But i would also want to know...  a method for figuring this out... hopefully a method that resides in management studio.

error and query is attached

sql profiler etc...
Who is Participating?
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.

Martyn SpencerSoftware Developer / Linux System Administrator / Managing DirectorCommented:
It appears to me that you have a column that contains a value that is defined as a character type and it contains the value "one" but you are comparing with an integer value. "One" cannot be converted to an integer representation. Are APPPAYKEY or APNO defined as a character? Can you include the table definitions?

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
slightwv (䄆 Netminder) Commented:
I assume SQL Server?

To locate the "bad data, look at the ISNUMERIC function:

You didn't provide the nvarchar column or which table it is in so something like:
select some_column from some_table where ISNUMERIC(some_column) <> 1;
Dustin SaundersDirector of OperationsCommented:
Easiest way IMO is just open the tables in SSMS and look at the column data types and see what doesn't match.  Or pop open designer and drop in the tables to get an overview.

Fundamentals of JavaScript

Learn the fundamentals of the popular programming language JavaScript so that you can explore the realm of web development.

slightwv (䄆 Netminder) Commented:
I might have misread the question but if I move the statements around a little, I thought it was:
"a method for figuring out rogue data in a column that shouldnt be there"
Dustin SaundersDirector of OperationsCommented:
@slightwv I think you're right and I mistook the question.

Is there a reason why constraints can't be introduced to your column?  If you go clean it up, how did the bad data get there and what happens when bad data gets inserted again?
jamesmetcalf74Author Commented:
Thanks Gentlemen -
both techniques were valuable
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

From novice to tech pro — start learning today.