Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Catch SQL Cast ERROR

Posted on 2007-10-03
2
Medium Priority
?
1,257 Views
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?
0
Comment
Question by:Rowdyone52
2 Comments
 
LVL 93

Accepted Solution

by:
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
0
 
LVL 66

Expert Comment

by:Jim Horn
ID: 20010297
SELECT YourColumnNameGoesHere
FROM YourTableNameGoesHere
WHERE ISDATE(YourColumnNameGoesHere) = 0
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