Jim Metcalf
asked on
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...
error.JPG
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...
error.JPG
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
@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?
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?
ASKER
Thanks Gentlemen -
both techniques were valuable
both techniques were valuable
To locate the "bad data, look at the ISNUMERIC function:
https://docs.microsoft.com/en-us/sql/t-sql/functions/isnumeric-transact-sql?view=sql-server-2017
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;