SQL Server: Function Evaluation Time -
SQL Server: Function Evaluation Time -
sql server 2005:
query below returns no info ((0 row(s) affected)), ok.
but when line #3 function phone call enabled, query fails!"conversion failed when converting datetime character string."
coming oracle background - unthinkable! please tell me what's going on - doing wrong ?doesn't ss evaluate function calls in select list @ lastly step (like oracle - or sensible programmer do) ?
select 1 1 --,datepart(yyyy,cast(inception_date27 datetime)) inception_yr [dbo].[h5_premium_detail] dtl, [dbo].[h5_policy_master] polmst polmst.policy_no2 = cast(dtl.arch_master_policy_no41 numeric) , len(inception_date27) != 8here little clip recorded
thanks
note: know root source of bad info (some rows have "0" instead of "20110704") ss complains here - the gist why failure arise no info found join.
doesn't ss evaluate function calls in select list @ lastly step (like oracle - or sensible programmer do) ?
no. (and - no).
the general rule in sql there's defined "order" in parts of query should appear processed, different database systems free re-order operations, provided end result same.
however, there's still room ambiguity, , sql server seems more systems force conversions before in process might otherwise expected - may that, given io overhead of operations, , expense of performing bring together operation (how big tables? type of bring together has optimizer selected?), performing conversion operation before bring together occurs practically free, that's optimizer has chosen do.
it nice if sql server mark such conversion failures in rows they're processed, , study @ end if result set still contains row conversion failure, that's not how works.
pushing of case look in select clause plenty (similar niktrs answer):
select /* other columns */ case when inception_date27 '[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]' datepart(year,convert(datetime,inception_date27)) end sql sql-server
Comments
Post a Comment