我的数据库中的列长度为零但不为null [英] I have columns in my database that are zero length but not null
问题描述
我不确定是否在列中,但它们不是null并且长度为零,我尝试了以下
I am not sure that is in the columns, but they are not null and have zero length, I have tried the following
和 ( data_value 。 string_value IS NOT NULL
and(data_value.string_valueISNOTNULL
OR LEN ( data_value 。 string_value ) > 0
ORLEN(data_value.string_value)>0
OR NULLIF ( LTRIM ( RTRIM ( data_value 。 跨度> string_value )), '' ) IS NOT NULL
ORNULLIF(LTRIM(RTRIM(data_value.string_value)),'')ISNOTNULL
或 data_value 。 string_value <> ''
ordata_value.string_value<>''
< span style ="color:#808080; font-size:small"> 或 COALESCE ( data_value 。 string_value , '' ) <> ''
orCOALESCE(data_value.string_value,'')<>''
或
COALESCE ( PATINDEX ( ' %[^
]%' , data_value < span style ="color:#8080 80; font-size:small"> 。 string_value ), 0 ) > 0
or COALESCE(PATINDEX('%[^ ]%',data_value.string_value),0)>0
或 NULLIF ( LTRIM ( RTRIM ( data_value 。 跨度> string_value )), '' ) IS NOT NULL)
orNULLIF(LTRIM(RTRIM(data_value.string_value)),'')ISNOTNULL)
我显示了 len ( data_value 。 string_value )
,它为零
I displayed len(data_value.string_value) and it is zero
我将列复制到notepad ++并点击显示所有没有显示任何内容的值
I copied the column into notepad++ and clicked show all values that it showed nothing
任何帮助理解这些列中的内容都将受到赞赏
Any help understanding what is in these columns would be appreciated
提前谢谢
< span style ="color:#808080; font-size:small">
推荐答案
我显示
len ( data_value 。 string_value )
且为零
I displayed len(data_value.string_value) and it is zero
LEN函数忽略尾随空格,因此零值表示它是空字符串或所有空格。
DATALENGTH(data_value.string_value)值为零表示空字符串,这是SQL Server中的有效值。其他一些DBMS产品不允许空字符串。
The LEN function ignores trailing spaces so the zero value indicates it is either an empty string or all spaces. A DATALENGTH(data_value.string_value) value of zero indicates an empty string, which is a valid value in SQL Server. Some other DBMS products do not allow empty strings.
如果DATALENGTH返回一个非零值,它可能是空白或不可显示的值。在T-SQL中,你可以使用
CAST(data_value.string_value AS varbinary(MAX))来查看存储在数据库中的位。
If DATALENGTH returns a non-zero value, it may be whitespace or non-displayable value. In T-SQL, you can use
CAST(data_value.string_value AS varbinary(MAX)) to see the bits as stored in the database.
这篇关于我的数据库中的列长度为零但不为null的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!