日期:2014-05-17 浏览次数:20575 次
select case when CONVERT(INT,log(16)/log(2))=log(16)/log(2) then '整除' ELSE '不整除' END
------
整除
(所影响的行数为 1 行)
1> declare @x int;
2> set @x=10;
3> select case when replace(substring(master.dbo.fn_varbintohexstr(CONVERT(VARBI
NARY(16),@x)),3,10),'0','') in ('','1','2','4','8') then 'OK' else 'FALSE' end
4>
5> go
-----
FALSE
(1 rows affected)
1> declare @x int;
2> set @x=64;
3> select case when replace(substring(master.dbo.fn_varbintohexstr(CONVERT(VARBI
NARY(16),@x)),3,10),'0','') in ('','1','2','4','8') then 'OK' else 'FALSE' end
4> go
-----
OK
(1 rows affected)
1>
declare @i int
set @i = 128
select case when(select count(1) from master..spt_values where number =log(@i)/log(2)) !=0
then '整除'
else '非整除'
end