HiveBrain v1.2.0
Get Started
← Back to all entries
debugsqlMinor

How to find column which causing "Conversion failed" error

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
conversionerrorhowcolumncausingfailedfindwhich

Problem

I've run into quite a lot of issues specially when it comes to conversion errors:
convert(datetime, [fieldname]) or SELECT CAST([field2] AS int).

Imagine a large select statement with 30+ conversion or cast functions, or a complex view with conversions, or even an insert statement on a field with wrong data type. I get so much headache trying to exclude fields one by one to find the troublemaker.

Is there a way to find out which field and/or value is causing the issue? How do people troubleshoot these without having to go through an arduous process of going field by field? Is there a log or information message that can help?

Solution

How do people troubleshoot these without having to go through an arduous process of going field by field?

Exclude half of them. If the error persists exclude half the remaining. Repeat.

Context

StackExchange Database Administrators Q#280968, answer score: 3

Revisions (0)

No revisions yet.