我目前有一个表t1,'\t'在我的FIELD TERMINATED子句中设置了一个值.
现在我想在表的 结构中更改该特定子句t1.
创作后ALTER的FIELD TERMINATED条款有什么办法吗?
输入中有脏数据.我们正在尝试清理数据集,然后对清除的数据进行一些计算.
declare @t table (str varchar(10))
insert into @t select '12345' union all select 'ABCDE' union all select '111aa'
;with prep as
(
select *, cast(substring(str, 1, 3) as int) as str_int
from @t
where isnumeric(substring(str, 1, 3)) = 1
)
select *
from prep
where 1=1
and case when str_int > 0 then 'Y' else 'N' end = 'Y'
--and str_int > 0
Run Code Online (Sandbox Code Playgroud)
最后两行正在做同样的事情.第一个工作,但如果你取消注释第二个它将崩溃Conversion failed when converting the varchar value 'ABC' to data type int.
显然,SQL Server正在重写将所有条件混合在一起的查询.我猜它认为'case'是一个havy操作并将其作为最后一步执行.这就是为什么解决方案有效的原因.
这种行为是以任何方式记录的吗?还是一个bug?