How does this CASE expression reach the ELSE clause?

前端 未结 3 1360
无人及你
无人及你 2020-11-29 07:18

I need to load some test data into the Channel field on my Account table. The Channel can be one of 10 different values, so I thought I\'d randomly assign the Channel one o

3条回答
  •  南笙
    南笙 (楼主)
    2020-11-29 08:08

    Related to second question,

    CHECKSUM(NewId()) will return negative results sometimes, which is not match with any of the case conditions. If a negative number is divided with any number the result will be negative. Execute the following query,

    declare @v nvarchar(50) = newid()
    select CHECKSUM(@v),@v,CHECKSUM(@v) % 10
    

提交回复
热议问题