Code 1CREATE FUNCTION [dbo].[BitMove](@long bigint,@operator varchar(3),@len int) 2RETURNS bigint AS 3BEGIN 4 if @len=0 5 return @long 6 declare @i bigint 7 declare @j bigint 8 set @i=cast(0x8000000000000000 as bigint) 9 set @j=cast(0x4000000000000000 as bigint)10 if @operator='<<'11 begin12 while @len>013 begin14 set @len=@len-115 if (@i&@long)=@i16 set @long=@long^@i17 if (@j&@long)=@j18 begin19 set @long=@long^@j20 set @long=@long*221 if @len=022 set @long=@long|@i23 end24 else25 set @long=@long*226 end27 end28 else29 begin30 set @len=@len-131 set @long=@long/232 if @operator='>>>' and (@i&@long)=@i33 set @long=@long^@i34 set @long=@long/power(2,@len)35 end36 return @long37END 转载于:https://www.cnblogs.com/wpg/articles/1338200.html