SQL出现将 varchar 值 '测试AA' 转换为数据类型为 int 的列时发生语法错误
如标题,sql语句如下selectt1.sub_dh,sum(casewhent2.sSC_Code='r14'thent2.sSC_Commentelse0end)as...
如标题,sql语句如下
select t1.sub_dh,
sum(case when t2.sSC_Code='r14' then t2.sSC_Comment else 0 end) as srr14
FROM dbo.A as t1
left join dbo.B as t2 on t2.sub_dh=t1.sub_dh
在表B中,ssc_COMMENT是varchar的格式,会出现文本形式,汉字等,一旦执行这句话,就出现如题的错误了,怎么弄?我改成
select t1.sub_dh,
sum(case when t2.sSC_Code='r14' then convert(int,t2.sSC_Comment) else 0 end) as srr14
FROM dbo.A as t1
left join dbo.B as t2 on t2.sub_dh=t1.sub_dh
还是不行
我不懂了 ,求大大神 展开
select t1.sub_dh,
sum(case when t2.sSC_Code='r14' then t2.sSC_Comment else 0 end) as srr14
FROM dbo.A as t1
left join dbo.B as t2 on t2.sub_dh=t1.sub_dh
在表B中,ssc_COMMENT是varchar的格式,会出现文本形式,汉字等,一旦执行这句话,就出现如题的错误了,怎么弄?我改成
select t1.sub_dh,
sum(case when t2.sSC_Code='r14' then convert(int,t2.sSC_Comment) else 0 end) as srr14
FROM dbo.A as t1
left join dbo.B as t2 on t2.sub_dh=t1.sub_dh
还是不行
我不懂了 ,求大大神 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询