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,')') endSQL案例情况,错误转换失败(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