SQL Server: Finding Bad Data

How to select all rows except those where I get an error message that causes CONVERTin one of the columns?

For example, I do this:

SELECT rowid 
FROM batchinfo 
WHERE CONVERT(DATE, reporttime, 101) between '2010-07-01' and '2010-07-31';

And I get errors for some values. I have two questions:

  • How to skip error lines?
  • How to get only error strings?
+3
source share
2 answers

You can use the ISDATE () function to check the values.

SELECT *
FROM MyTable
WHERE ISDATE(MyColumn) != 1
+7
source

I believe you can use the IGNORE statement for this, but I could be wrong.

-1
source

Source: https://habr.com/ru/post/1761817/


All Articles