@BeginTime INT
@EndTime INT
set @BeginTime= 1
set @EndTime= 180000   --打乱多少次，比GameIdentifier表最大的 UserID 小一些

@FirstID INT
@SecondID INT
@FirstTempID INT
@SecondTempID INT

@MaxD INT
@INT

select  @MaxD=count()   from [QPGameUserDB].[dbo].[GameIdentifier]
set  @= len(CONVERT(10), @MaxD))

while (@BeginTime<@EndTime)
BEGIN

set @FirstID= @BeginTime+(cast((cast(power(10,(cast((@Count-1)rand(checksum(newid())) as int)+1)) as int))rand(checksum(newid())) as int))+1
set @SecondID= @MaxD-(cast((cast(power(10,(cast((@Count-1)rand(checksum(newid())) as int)+1)) as int))rand(checksum(newid())) as int))+1
select   @FirstID, @SecondID ,@MaxD
if @FirstID > @MaxD
begin
set @FirstID=@MaxD-(cast((cast(power(10,(cast((@Count-2)rand(checksum(newid())) as int)+1)) as int))rand(checksum(newid())) as int))
end
if @SecondID > @MaxD
begin
set @SecondID=@MaxD-(cast((cast(power(10,(cast((@Count-1)rand(checksum(newid())) as int)+1)) as int))rand(checksum(newid())) as int))
end
select   @FirstID, @SecondID, @MaxD
select @FirstTempID = GameID from GameIdentifier where UserID
select @SecondTempID = GameID from GameIdentifier where UserID

-- select @FirstTempID , @SecondTempID

update GameIdentifier set GameID = GameID10 where UserID
update GameIdentifier set GameID = @FirstTempID where UserID
update GameIdentifier set GameID = @SecondTempID where UserID

select @FirstTempID = GameID from GameIdentifier where UserID
select @SecondTempID = GameID from GameIdentifier where UserID
-- select @FirstTempID , @SecondTempID

SET @BeginTime=@BeginTime+1
END