如何在 sql 中将 BIT 数据类型转换为 Varchar?
我试过 CAST
CAST(IsDeleted as Varchar(512))
但它没有工作....
注意:IsDeleted是 BIT 数据类型,我需要将其转换为 Varchar 或 Int
SELECT
CASE WHEN IsDeleted = 1 THEN 'True' ELSE 'False' END AS IsDel
FROM
Table
是属性nullable
?
尝试
CONVERT(varchar, ISNULL(isDeleted,0))
CAST(IsDeleted AS INT) AS IsDeleted
这应该可以,我刚刚在 SSMS 中尝试过,它就像一个魅力