搜索
 找回密码
 加入

查复制SQL

dxd123456 2009-11-24 22:26:09 1233
  1.              CREATE TABLE ITEM_DECODED(
  2.               strUserID char(21) NULL DEFAULT ('-'),
  3.               strAccountID char(21) NULL DEFAULT ('-'),
  4.               Name varchar(50),
  5.               dwID int NULL,
  6.               strSerial varchar(50) null,
  7.               Durability int NULL,
  8.               StackSize smallint NULL,
  9.              ii [int] NULL
  10.             )
  11.             CREATE TABLE DUPERS_LOGGED(
  12.               strUserID varchar(50) NULL DEFAULT ('-'),
  13.               strAccountID varchar(21) NULL DEFAULT ('-'),
  14.               Name char(50) NULL,
  15.               dwID int NULL,
  16.               strSerial varchar(50) null,
  17.               time smalldatetime NULL DEFAULT (getdate()),
  18.               ii smallint NULL
  19.               )   

  20. CREATE PROCEDURE xiandai_clear
  21.        
  22. AS
  23. BEGIN
  24.        
  25.         SET NOCOUNT ON;
  26.               declare @StrUserID char(21)
  27.               truncate table ITEM_clone
  28.               truncate table item_decoded
  29.               DECLARE Backup_Cursor CURSOR
  30.               FOR
  31.               SELECT struserID from userdata
  32.               OPEN Backup_Cursor
  33.               FETCH NEXT FROM Backup_Cursor INTO @StrUserID
  34.               WHILE @@FETCH_STATUS = 0
  35.               BEGIN
  36.               DECLARE @row int, @i int, @count int, @dwid int, @type
  37.               varbinary(4), @StackSize int, @strSerial char(50), @name char(50)
  38.               SET @i = 1
  39.               set @name = ''
  40.               WHILE @i <401
  41.               BEGIN
  42.               SELECT @dwid = cast(cast(substring(cast(strItem as varbinary(400)), @i + 4, 1)+substring(cast(strItem as varbinary(400)), @i + 3, 1)+substring(cast(strItem as varbinary(400)),  @i + 2 , 1)+substring(cast(strItem as varbinary(400)),@i + 1 , 1) as varbinary(4)) as int(4)),
  43.               @strSerial = cast(cast(substring(cast(strSerial as varbinary(400)),@i + 8,  1)+substring(cast(strSerial as varbinary(400)),@i + 7 , 1)+substring(cast(strSerial as varbinary(400)),@i + 6 , 1)+substring(cast(strSerial as varbinary(400)), @i + 5 , 1)+substring(cast(strSerial as varbinary(400)),@i + 4 , 1)+substring(cast(strSerial as varbinary(400)),@i + 3 , 1)+substring(cast(strSerial as varbinary(400)), @i + 2 , 1)+substring(cast(strSerial as varbinary(400)),@i + 1 , 1) as varbinary(8)) as bigint),
  44.               @type = cast(substring(strItem, @i+4, 2) as varbinary(2)),
  45.               @StackSize = cast(cast(cast( substring(strItem, @i+7, 1) as
  46.               varbinary(1))+cast(substring(strItem, @i+6, 1) as varbinary(1)) as
  47.               varbinary(2)) as smallint)
  48.               FROM USERDATA
  49.               WHERE strUserID = @StrUserID

  50.               select @name = strname from item where num = @dwid
  51.               IF @dwid <> 0
  52.               INSERT INTO ITEM_DECODED (strUserID, Name, dwid, strSerial,
  53.               Durability, StackSize, ii)
  54.               VALUES (@StrUserId, @Name, @dwid, @strSerial, @type, @StackSize,
  55.               (@i-1) / 8)
  56.               SET @i = @i + 8
  57.               END
  58.               FETCH NEXT FROM Backup_Cursor INTO @StrUserID
  59.               END
  60.               CLOSE Backup_Cursor
  61.               DEALLOCATE Backup_Cursor

  62. --仓库里复制的东西

  63.               DECLARE Backup_Cursor CURSOR
  64.               FOR
  65.               SELECT struserID from userdata
  66.               OPEN Backup_Cursor
  67.               FETCH NEXT FROM Backup_Cursor INTO @StrUserID
  68.               WHILE @@FETCH_STATUS = 0
  69.               BEGIN
  70. --             DECLARE @row int, @i int, @count int, @dwid int, @type
  71. --             varbinary(4), @StackSize int, @strSerial char(50), @name char(50)
  72.               SET @i = 1
  73.               set @name = ''
  74.               WHILE @i <192
  75.               BEGIN
  76.               SELECT @dwid = cast(cast(substring(cast(WarehouseData as varbinary(1600)),@i + 4 , 1)+substring(cast(WarehouseData as varbinary(1600)), @i+ 3 , 1)+substring(cast(WarehouseData as varbinary(1600)), @i + 2 , 1)+substring(cast(WarehouseData as varbinary(1600)),@i+ 1 , 1) as varbinary(4)) as int(4)),
  77.               @strSerial = cast(cast(substring(cast(strSerial as varbinary(1600)),@i + 8 , 1)+substring(cast(strSerial as varbinary(1600)),@i + 7 , 1)+substring(cast(strSerial as varbinary(1600)),@i + 6, 1)+substring(cast(strSerial as varbinary(1600)),@i + 5 , 1)+substring(cast(strSerial as varbinary(1600)), @i + 4 , 1)+substring(cast(strSerial as varbinary(1600)),@i + 3, 1)+substring(cast(strSerial as varbinary(1600)), @i+ 2 , 1)+substring(cast(strSerial as varbinary(1600)),@i+ 1 , 1) as varbinary(8)) as bigint),
  78.               @type = cast(cast(substring(cast(WarehouseData as varbinary(1600)),@i + 6 , 1)+substring(cast(WarehouseData as varbinary(1600)), @i + 5 , 1) as varbinary(2)) as smallint(2)) ,
  79.               @StackSize = cast(cast(substring(cast(WarehouseData as varbinary(1600)),@i + 8 , 1)+substring(cast(WarehouseData as varbinary(1600)), @i + 7 , 1) as varbinary(2)) as smallint(2))
  80.               from WAREHOUSE inner join account_char on warehouse.strAccountId=account_char.strAccountId                
  81.               WHERE account_char.strCharId1= @StrUserID

  82.               select @name = strname from item where num = @dwid
  83.               IF @dwid <> 0
  84.               INSERT INTO ITEM_DECODED (strUserID, Name, dwid, strSerial,
  85.               Durability, StackSize, ii)
  86.               VALUES (@StrUserId, @Name, @dwid, @strSerial, @type, @StackSize,
  87.               (@i-1) / 8)
  88.               SET @i = @i + 8
  89.               END
  90.               FETCH NEXT FROM Backup_Cursor INTO @StrUserID
  91.               END
  92.               CLOSE Backup_Cursor
  93.               DEALLOCATE Backup_Cursor

  94. --清装备
  95.                        
  96.               DECLARE @rowcount int
  97.               declare @sSerial  char(50)

  98.               declare @fz int
  99.               declare @strAccoutID char(30)
  100.               select @rowcount=max(Id) from item_decoded
  101.               SET @i = 1              
  102.               WHILE @i <@rowcount
  103.               BEGIN            
  104.               select @StrUserID=struserID,@sSerial=strSerial from item_decoded where id =@i
  105.               select @fz=count(strSerial) from item_decoded where strSerial=@sSerial and strSerial<>'0' and id<>@i and strSerial <> '74601890051852267'
  106.               if @fz>0              
  107.               begin
  108.               --select @sSerial
  109.               --select @fz
  110.               update USERDATA set stritem='',strserial='',gold=0 where struserId=@StrUserID
  111.               select @strAccoutID=straccountId from account_char where strCharId1=@StrUserID
  112.               update WAREHOUSE set strserial='',warehousedata='' where strAccountId=@strAccoutID
  113.                                        
  114.             
  115.               INSERT INTO ITEM_clone (strUserID, [Name], dwid, strSerial,
  116.                 ii)
  117.               VALUES (@StrUserId, '','', @sSerial,               (@i-1) / 8)
  118.                end  
  119.               SET @i = @i + 1
  120.               END

  121.    
  122. END
  123. GO
复制代码

0 回复

高级模式
游客