Learn how to a build a cloud-first strategyRegister Now


Catch SQL Cast ERROR

Posted on 2007-10-03
Medium Priority
Last Modified: 2012-05-05
I need to find all instances where a field cannot be cast to date time.  How can I select all fields that fail the cast?
Question by:Rowdyone52
LVL 93

Accepted Solution

Patrick Matthews earned 2000 total points
ID: 20010287
SELECT (CASE WHEN ISDATE(SomeColumn) = 1 THEN CAST(SomeColumn AS datetime) ELSE NULL END) AS foo
FROM SomeTable
LVL 66

Expert Comment

by:Jim Horn
ID: 20010297
SELECT YourColumnNameGoesHere
FROM YourTableNameGoesHere
WHERE ISDATE(YourColumnNameGoesHere) = 0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article, we’ll look at how to deploy ProxySQL.
Creating a Cordova application which allow user to save to/load from his Dropbox account the application database.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Viewers will learn how the fundamental information of how to create a table.
Suggested Courses

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question