SQL案例情况,错误转换失败(SQL case condition with error failed converting)

编程入门 行业动态 更新时间:2024-10-08 10:33:59
SQL案例情况,错误转换失败(SQL case condition with error failed converting)

我有这个查询导致此错误:

将varchar值')'转换为数据类型tinyint时失败。

这是我的代码有问题:

select case t.name when 'numeric' then cast (c.precision + ')' as varchar(100)) end from sys.columns c inner join sys.types t ON t.user_type_id = c.user_type_id inner join sys.tables tb on tb.name = 'EX_EMPLOYEE' where c.name = 'B_CODE' and tb.object_id = c.object_id

I have this query that causes this error:

Failed when converting the varchar value ')' to data type tinyint.

This is my code in question:

select case t.name when 'numeric' then cast (c.precision + ')' as varchar(100)) end from sys.columns c inner join sys.types t ON t.user_type_id = c.user_type_id inner join sys.tables tb on tb.name = 'EX_EMPLOYEE' where c.name = 'B_CODE' and tb.object_id = c.object_id

最满意答案

也许(如果2012+)

case t.name when 'numeric' then concat(c.precision,')') end

Perhaps (if 2012+)

case t.name when 'numeric' then concat(c.precision,')') end

更多推荐

本文发布于:2023-08-07 18:24:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1465276.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:错误   案例   情况   SQL   case

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!