-
您的位置:首页 → 精文荟萃 → 软件资讯 → 传奇3.0常要用到的SQL脚本
传奇3.0常要用到的SQL脚本
时间:2004/10/7 18:21:00来源:本站整理作者:蓝点我要评论(0)
-
常要用到的SQL脚本
|
--说明:此SQL脚本专为删除复制装备而写
--思路:将所有玩家仓库/身上/包袱中的装备全部放入一个临时表,再从临时表中查询MAKEINDEX重复的装备并遂个删除
-- 删除的记录记在日志文件TBL__DELLOG中。
--日期:2003/04/29
--修正日期:2003/05/20
--改进了算法,只列出makeindex相同且装备代码相同的物品。
--改动处:LTRIM(STR([FLD_MAKEINDEX]))+LTRIM(STR([FLD_INDEX])) AS FLD_TID
USE muddb
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 [muddb].[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 [muddb].[dbo].[TBL_ITEM],[muddb].[dbo].[StdItems]
WHERE [FLD_INDEX]-1=[Idx]
GO
--从仓库获取数据
INSERT INTO [muddb].[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 [muddb].[dbo].[TBL_SAVEDITEM],[muddb].[dbo].[StdItems]
WHERE [FLD_INDEX]-1=[Idx]
GO
--记录将要删除的复制装备
if not exists (select * from dbo.sysobjects where id = object_id(N'[muddb].[dbo].[TBL__DELLOG]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
CREATE TABLE [muddb].[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 [muddb].[dbo].[TBL__DELLOG]([删除日期],[FLD_MAKEINDEX],[装备代码],[装备名称],[角色名],[存放地点])
SELECT getdate() as 删除日期,[FLD_MAKEINDEX] , [FLD_INDEX]-1 AS 装备代码,[Name] AS 装备名称,[FLD_CHARACTER] AS 角色名, [Place] AS 存放地点
FROM [muddb].[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 [muddb].[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 [muddb].[dbo].[TBL_SAVEDITEM] WHERE [FLD_MAKEINDEX] = @I_MAKEINDEX
ELSE
DELETE FROM [muddb].[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]
GO
相关阅读
Windows错误代码大全 Windows错误代码查询激活windows有什么用Mac QQ和Windows QQ聊天记录怎么合并 Mac QQ和Windows QQ聊天记录Windows 10自动更新怎么关闭 如何关闭Windows 10自动更新windows 10 rs4快速预览版17017下载错误问题Win10秋季创意者更新16291更新了什么 win10 16291更新内容windows10秋季创意者更新时间 windows10秋季创意者更新内容kb3150513补丁更新了什么 Windows 10补丁kb3150513是什么
-
热门文章
360快剪辑怎么使用 36金山词霸如何屏幕取词百度收购PPS已敲定!3
最新文章
微信3.6.0测试版更新了微信支付漏洞会造成哪
360快剪辑怎么使用 360快剪辑软件使用方法介酷骑单车是什么 酷骑单车有什么用Apple pay与支付宝有什么区别 Apple pay与贝贝特卖是正品吗 贝贝特卖网可靠吗
人气排行
xp系统停止服务怎么办?xp系统升级win7系统方电脑闹钟怎么设置 win7电脑闹钟怎么设置office2013安装教程图解:手把手教你安装与qq影音闪退怎么办 QQ影音闪退解决方法VeryCD镜像网站逐个数,电驴资料库全集同步推是什么?同步推使用方法介绍QQ2012什么时候出 最新版下载EDiary——一款好用的电子日记本
查看所有0条评论>>