在 TSQL 的一个存储过程中,我遇到了代码
Alter procedure Name
@parameter1 ,
@parameter2 ,
..........
if (substring(@bitmap,1,1) & 1 = 1) or //what does this mean?
(substring(@bitmap,1,1) & 2 = 2) or
(substring(@bitmap,1,1) & 4 = 4) or
(substring(@bitmap,1,1) & 128 = 128) or
(substring(@bitmap,2,1) & 1 = 1)
[Column1] = case substring(@bitmap,1,1) & 1 when 1 then @parameter1 else [Column1] end,
[Column2] = case substring(@bitmap,1,1) & 2 when 2 then @parameter2 else [Column2] end,
[Column3] = case substring(@bitmap,1,1) & 4 when 4 then @parameter3 else [Column3] end,
[Column4] = case substring(@bitmap,1,1) & 8 when 8 then @parameter4 else [Column4] end,
[Column5] = case substring(@bitmap,1,1) & 16 when 16 then @parameter5 else [Column5] end,
[Column6] = case substring(@bitmap,1,1) & 32 when 32 then @parameter6 else [Column6] end,
[Column7] = case substring(@bitmap,1,1) & 64 when 64 then @parameter7 else [Column7]end,
[Column8] = case substring(@bitmap,1,1) & 128 when 128 then @parameter8 else [Column8] end,
[Column9] = case substring(@bitmap,2,1) & 1 when 1 then @parameter9 else [Column9] end,
[Column10] = case substring(@bitmap,2,1) & 2 when 2 then @parameter10 else [Column10] end
谷歌搜索我发现它有助于动态构建过程。但我仍然有几个疑问。
(substring(@bitmap,1,1) & 1 = 1) or //what does this mean?
substring(@bitmap,2,1) & 1 when 1 then @parameter9 else [Column9] end,//what does this mean
case SUBSTRING(@bitmap,1,1) & 256 when 256 or
case SUBSTRING(@bitmap,1,1) & 512 when 512
谢谢