Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
slserra
Starting Member
19 Posts |
Posted - 2005-06-21 : 13:35:51
|
| When I do a select against a table with a computed column and one of the computations results in an error the query stops executing. Is there a way to have the query continue to execute and have the 'error' computation display as null?For example, I have the following table of strings:strDate--------6/20/20056/21/20056/226/23/2005I add a computed column as 'cast([strDate] as datetime) as calcDate'when I select all, I would like the results to show:strDate calcDate-------- --------6/20/2005 6/20/20056/21/2005 6/21/20056/22 null6/23/2005 6/23/2005without any error or warning messages.I see that I can use SET ARITHABORT and SET ARITHIGNORE to handle divide by 0 situations but these settings do not seem to have any impact on other types of errors.Any help is appreciated.Steve |
|
|
ditch
Master Smack Fu Yak Hacker
1466 Posts |
Posted - 2005-06-21 : 13:46:09
|
| No - I don't think so.but you can handle it in your code:create table #test(strDate varchar(10))insert into #testselect '6/20/2005' unionselect '6/21/2005' unionselect '6/22' unionselect '6/23/2005'select strDate, case when isdate(strdate) = 1 then cast(strdate as datetime) else null endfrom #testdrop table #testDuane. |
 |
|
|
|
|
|