Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL Server: finding the bad data

Tags:

sql

sql-server

How do I select all rows except for ones that where I get an error calling CONVERT on one of the columns?

For example, I am doing this:

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

And I am getting errors for some of the values. I have two questions:

  1. How can I skip the rows that have errors?
  2. How can I get only the rows that have errors?
like image 442
Alex Gordon Avatar asked Aug 26 '10 21:08

Alex Gordon


1 Answers

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

SELECT *
FROM MyTable
WHERE ISDATE(MyColumn) != 1
like image 158
bobs Avatar answered Sep 22 '22 08:09

bobs