if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[BRATE_DROP]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)drop table [dbo].[BRATE_DROP]GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[BRATE_UPGRADE]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)drop table [dbo].[BRATE_UPGRADE]GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[BRATE_EXCHANGE]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)drop table [dbo].[BRATE_EXCHANGE]GO
CREATE TABLE [dbo].[BRATE_DROP] ( [itemNo] [int] NOT NULL ) ON [PRIMARY]GO
CREATE TABLE [dbo].[BRATE_UPGRADE] ( [itemNo] [int] NOT NULL ) ON [PRIMARY]GO
CREATE TABLE [dbo].[BRATE_EXCHANGE] ( [itemNo] [int] NOT NULL ) ON [PRIMARY]GO
truncate table BRATE_UPGRADEinsert into BRATE_UPGRADE (itemno) select num from item where num like '%8'insert into BRATE_UPGRADE (itemno) select num from item where itemtype=4 and slot in(10,11,12,14)truncate table BRATE_DROPinsert into BRATE_DROP (itemno) select num from item where itemtype=4truncate table BRATE_EXCHANGEinsert into BRATE_EXCHANGE (itemno) select nExchangeItemNum1 from ITEM_EXCHANGE where nExchangeItemNum1 in(select num from item where itemtype=4)insert into BRATE_EXCHANGE (itemno) select nExchangeItemNum2 from ITEM_EXCHANGE where nExchangeItemNum2 in(select num from item where itemtype=4) and not nExchangeItemNum2 in(select itemno from BRATE_EXCHANGE) insert into BRATE_EXCHANGE (itemno) select nExchangeItemNum3 from ITEM_EXCHANGE where nExchangeItemNum3 in(select num from item where itemtype=4) and not nExchangeItemNum3 in(select itemno from BRATE_EXCHANGE) insert into BRATE_EXCHANGE (itemno) select nExchangeItemNum4 from ITEM_EXCHANGE where nExchangeItemNum4 in(select num from item where itemtype=4) and not nExchangeItemNum4 in(select itemno from BRATE_EXCHANGE) insert into BRATE_EXCHANGE (itemno) select nExchangeItemNum5 from ITEM_EXCHANGE where nExchangeItemNum5 in(select num from item where itemtype=4) and not nExchangeItemNum5 in(select itemno from BRATE_EXCHANGE)