views:

32

answers:

1

I have a view which has started causing the following error:

Msg 245, Level 16, State 1, Line 1
Conversion failed when converting the varchar value 'R1500051' to data type int.

The problem is, the query is quite big and complex (several sub queries, joins and function calls) and I have no idea where that error is actually coming from. I've tried commenting bits out but that doesn't really help very much (think the error may be coming in more than one place)

It would really help if I could see exactly what was being executed at the time this error was thrown, e.g. if it's a function that's causing the error.

If anyone has any advice about that it would be really useful.

A: 

You could use SQL Profiler if you have access. I, personally, find these errors when I'm joining ID columns or during a UNION. It's a PITA, but you could check your subqueries and see what comes back, then check what columns it's supposed to join on and check the data type. Or you could spend a couple more hours trolling on SO/TechNet/SQLServerCentral/etc... =]

Vinnie