How to fix a SQL query that fails when pulling data from a specific column?

Viewed 180

I have a particular SELECT * FROM DB query that pulls from a SQL view. However, it fails with an

error 17310: cannot complete query because it is in a kill state (LOG: exception_access_violation).

I've traced it down to a single column of information that is causing the issue. If I specify all other columns but this specific one, it works fine. If I pull the top 1000 records, including the bad column, it works fine. If I query that one, bad column but filter the results, it works fine.

I'm running SQL Server 2016 and have installed all cumulative updates (12). I'm at a loss for what's going on and any assistance is appreciated.

1 Answers

So you can pull some rows which include the column, but not others?

In that case, you want to narrow it down to also know which row(s) ares bad, so you can find the commonality between them. Write a loop to query every row, one at a time, and use print statements to record progress. This should help you find the bad rows. Alternatively, if the data is organized well and we think there is only one problem row, you try a binary search, selecting half at a time to narrow it down more quickly.

Finally, when is the last time you ran dbcc checkdb (and actually looked through the results)?

Related