How can I gracefully handle bad date integers that are random thorughout my table? For instance I see some 9999999999 in there at times so consequently this query bombs out. I want to just produce the 1900 date in those cases instead of just stopping like this:
Select convert(date,CAST(trandate as varchar(8))),
convert(date,CAST(duedate as varchar(8))),
...
FROM SomeTable
a valid date looks like this in that table for those fields: 20100924 and those work fine when they hit this query.
You can use the isdate built-in function in sql server to check if something is castable to a date and then handle it however.
Example: