||首页▶▶ 正文

《王者传奇3私服》数据库下可用的删除复制装备的SQL脚本

♚ PK773传奇3信息港 ♛ 传奇3 ⏰ 2023-07-31 👀 457

    ‌‍注意:
    1、这个SQL脚本专用于使用A1.2插件的王者数据库的传3服务器,其他的服务器不要用。
    2、使用之前请切记备份数据库,以免发生失误!
    
    脚本如下:
    
    
    --修改者:星海追月(星剑)
    --修改自:根据口吃的男人做作的老EI3的SQL脚本修改而来
    --说明:此SQL脚本专为删除复制装备而写
    --修改*期:2005/1/12
    --删除的记录记在*志文件TBL__DELLOG中。
    --感谢口吃的男人、非凡龙天子等
    
    USE game1
    GO
    ---建立临时表
    if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TBL_ALLITEM]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
    drop table [dbo].[TBL_ALLITEM]
    GO
    
    CREATE TABLE [dbo].[TBL_ALLITEM] (
    [FLD_CHARACTER] [char] (15) COLLATE Chinese_PRC_CI_AS NOT NULL ,
    [FLD_TYPE] [tinyint] NULL ,
    [FLD_MAKEINDEX] [int] NOT NULL ,
    [FLD_TID] [varchar] (30) NOT NULL ,
    [FLD_INDEX] [int] NOT NULL ,
    [Name] [varchar] (30) COLLATE Chinese_PRC_CI_AS NULL,
    [Place] [varchar] (10) COLLATE Chinese_PRC_CI_AS NULL
    ) ON [PRIMARY]
    GO
    
    --从玩家身上/包袱获取数据
    INSERT INTO [game1].[dbo].[TBL_ALLITEM]([FLD_CHARACTER], [FLD_TYPE], [FLD_MAKEINDEX],[FLD_TID],[FLD_INDEX],[Name],[Place])
    SELECT [FLD_CHARACTER], [FLD_TYPE], [FLD_MAKEINDEX], LTRIM(STR([FLD_MAKEINDEX]))+LTRIM(STR([FLD_INDEX])) AS FLD_TID,[FLD_INDEX],[Name],'身上' AS Place
    FROM [game1].[dbo].[TBL_ITEM],[KingForEiServerBaseData].[dbo].[StdItems]
    WHERE [FLD_INDEX]-1=[Idx]
    GO
    
    --从仓库获取数据
    INSERT INTO [game1].[dbo].[TBL_ALLITEM]([FLD_CHARACTER], [FLD_TYPE], [FLD_MAKEINDEX],[FLD_TID],[FLD_INDEX],[Name],[Place])
    SELECT [FLD_CHARACTER], [FLD_TYPE], [FLD_MAKEINDEX], LTRIM(STR([FLD_MAKEINDEX]))+LTRIM(STR([FLD_INDEX])) AS FLD_TID,[FLD_INDEX],[Name],'仓库' AS Place
    FROM [game1].[dbo].[TBL_SAVEDITEM],[KingForEiServerBaseData].[dbo].[StdItems]
    WHERE [FLD_INDEX]-1=[Idx]
    GO
    
    --记录将要删除的复制装备
    if not exists (select * from dbo.sysobjects where id = object_id(N'[game1].[dbo].[TBL__DELLOG]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
    CREATE TABLE [game1].[dbo].[TBL__DELLOG] (
    [删除*期] datetime not null,
    [FLD_MAKEINDEX] [int] NOT NULL ,
    [角色名] [char] (15) COLLATE Chinese_PRC_CI_AS NOT NULL ,
    [装备代码] [int] NULL ,
    [装备名称] [varchar] (30) COLLATE Chinese_PRC_CI_AS NULL,
    [存放地点] [varchar] (10) COLLATE Chinese_PRC_CI_AS NULL
    ) ON [PRIMARY]
    
    GO
    
    INSERT INTO [game1].[dbo].[TBL__DELLOG]([删除*期],[FLD_MAKEINDEX],[装备代码],[装备名称],[角色名],[存放地点])
    SELECT getdate() as 删除*期,[FLD_MAKEINDEX] , [FLD_INDEX]-1 AS 装备代码,[Name] AS 装备名称,[FLD_CHARACTER] AS 角色名, [Place] AS 存放地点
    FROM [game1].[dbo].[TBL_ALLITEM]
    WHERE ((([FLD_TID]) In
    (SELECT [FLD_TID] FROM [TBL_ALLITEM] As Tmp GROUP BY [FLD_TID] HAVING Count([FLD_TID])>1 )))
    ORDER BY [FLD_MAKEINDEX]
    
    GO
    --遂个删除复制装备
    DECLARE @T_ID char (30),@I_MAKEINDEX int , @V_Place varchar (10)
    DECLARE D_ITEMS_cursor CURSOR FOR
    
    SELECT [FLD_TID],[FLD_MAKEINDEX],[Place]
    FROM [game1].[dbo].[TBL_ALLITEM]
    WHERE ((([FLD_TID]) In
    (SELECT [FLD_TID] FROM [TBL_ALLITEM] As Tmp GROUP BY [FLD_TID]
    HAVING Count([FLD_TID])>1 )))
    ORDER BY [FLD_MAKEINDEX]
    
    OPEN D_ITEMS_cursor
    
    FETCH NEXT FROM D_ITEMS_cursor INTO @T_ID,@I_MAKEINDEX,@V_Place
    
    WHILE @@FETCH_STATUS = 0
    
    BEGIN
    
    BEGIN
    IF @V_Place = '仓库'
    DELETE FROM [game1].[dbo].[TBL_SAVEDITEM] WHERE [FLD_MAKEINDEX] = @I_MAKEINDEX
    ELSE
    DELETE FROM [game1].[dbo].[TBL_ITEM] WHERE [FLD_MAKEINDEX] = @I_MAKEINDEX
    END
    
    FETCH NEXT FROM D_ITEMS_cursor INTO @T_ID,@I_MAKEINDEX,@V_Place
    
    END
    
    CLOSE D_ITEMS_cursor
    DEALLOCATE D_ITEMS_cursor
    
    GO
    
    if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TBL_ALLITEM]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
    drop table [dbo].[TBL_ALLITEM]
    
    


版权声明

转载文章仅代表原作者观点,不代表PK773传奇3私服发布站立场。
若为本站原创文章,转载请注明出处及链接。