C# 如何在sql中将位数据类型转换为varchar
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17220642/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
how to convert bit datatype to varchar in sql
提问by user2327795
How to convert BIT datatype to Varchar in sql ?
如何在 sql 中将 BIT 数据类型转换为 Varchar?
I tried CAST
我试过 CAST
CAST(IsDeleted as Varchar(512))
CAST(IsDeleted as Varchar(512))
But it didn't work....
但它没有用......
Note: IsDeletedis a BIT datatype and I need to convert it into Varchar or Int
注意:IsDeleted是 BIT 数据类型,我需要将其转换为 Varchar 或 Int
采纳答案by Ed Gibbs
回答by David Scott
CAST(IsDeleted AS INT) AS IsDeleted
This should work I just tried it in SSMS and it works like a charm
这应该可以工作,我刚刚在 SSMS 中尝试过,它的作用就像一个魅力
回答by user2407394
SELECT
CASE WHEN IsDeleted = 1 THEN 'True' ELSE 'False' END AS IsDel
FROM
Table
回答by Keith
is the attribute nullable?
是属性nullable?
Try
尝试
CONVERT(varchar, ISNULL(isDeleted,0))

