嗨我正在使用SQL Server 2012..Recently我正在努力从数据库的每个表中获取行数。我发现有4种不同的方法来获得它但是我发现的快速1是使用分区统计信息,即“ dm_db_partition_stats ”和“ sys.objects ”。 然而,在进行连接时,我会看到它使用的条件,如“ is_ms_shipped = 0x0 ”。 我的问题是使用“ is_ms_shipped = 0 ”和“ is_ms_shipped = 0x0 ”之间有什么区别吗? 有人可以帮我解决这个问题吗?
Hi i am using SQL Server 2012.Recently i was working on getting count of rows from each table for a Database.I found there were 4 different ways to get that but the 1 which is fast i found is using Partition stats i.e. "dm_db_partition_stats" and "sys.objects". However while making join i see in where condition it used like "is_ms_shipped=0x0". My question is there any difference between using "is_ms_shipped=0" and "is_ms_shipped=0x0" ? can somebody please help me to get this?
最满意答案
0x0是数据类型varbinary(1)和值0x00的文字。 (单个字节,所有位都设置为0)。
二进制数据类型具有最低的数据类型优先级,因此如果与bit进行比较,它将隐式转换为该数据类型。 结果为0 。
你应该只使用0,因为它避免了使用0x0的隐式转换和不必要的混淆。
0x0 is a literal of datatype varbinary(1) and value 0x00. (A single byte with all bits set to 0).
The binary datatypes have the lowest data type precedence so if compared against a bit column it will get implicitly cast to that datatype. Resulting in 0.
You should just use 0 as it avoids the implicit cast and unnecessary obfuscation of using 0x0.
更多推荐
发布评论