View Single Post
Old 23.06.2007, 19:11   #7
Le][u$
Архивный участник
 
Join Date: Aug 2006
Posts: 57
Default

Code:
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author:	Le][u$
-- Create date: xx.xx.2007
-- Description:	Remove deleted chars from DB
-- =============================================
CREATE PROCEDURE [dbo].[char_delete]
  AS
DECLARE @i INT
DECLARE @a INT
DECLARE @limit INT
set @i = (SELECT count(*) FROM user_data WHERE account_id = -1)
set @a = 0
WHILE @a < @i
BEGIN
SELECT TOP 1 @limit = char_id FROM user_data WHERE account_id = -1
DELETE FROM user_data WHERE char_id = @limit
DELETE FROM user_surrender WHERE char_id = @limit
DELETE FROM user_subjob WHERE char_id = @limit
DELETE FROM user_sociality WHERE char_id = @limit
DELETE FROM user_skill_old WHERE char_id = @limit
DELETE FROM user_skill WHERE char_id = @limit
DELETE FROM user_recipe WHERE char_id = @limit
DELETE FROM user_punish WHERE char_id = @limit
DELETE FROM user_nobless WHERE char_id = @limit
DELETE FROM user_newbie WHERE char_id = @limit
DELETE FROM user_macroinfo
WHERE user_macroinfo.macro_id in (SELECT distinct user_macro.macro_id
FROM user_macro join user_macroinfo on (user_macro.macro_id = user_macroinfo.macro_id)
WHERE user_macro.char_id = @limit)
DELETE FROM user_macro WHERE char_id = @limit
DELETE FROM user_log WHERE char_id = @limit
DELETE FROM user_journal WHERE char_id = @limit
DELETE FROM user_item WHERE char_id = @limit AND warehouse <> 2
DELETE FROM user_history WHERE char_id = @limit
DELETE FROM user_henna WHERE char_id = @limit
DELETE FROM user_friend WHERE char_id = @limit
DELETE FROM user_data_moved WHERE char_id = @limit
DELETE FROM user_data WHERE char_id = @limit
DELETE FROM user_comment WHERE char_id = @limit
DELETE FROM user_ActiveSkill WHERE char_id = @limit
DELETE FROM ssq_user_data WHERE char_id = @limit
DELETE FROM quest WHERE char_id = @limit
DELETE FROM olympiad_result WHERE char_id = @limit
DELETE FROM olympiad_match WHERE char_id = @limit
DELETE FROM nobless_achievements WHERE char_id = @limit
DELETE FROM ch3_lotto_char WHERE char_id = @limit
DELETE FROM bookmark WHERE char_id = @limit
set @a = @a+1
END
just deleted all removed chars (account_id=-1) from DB.
Le][u$ is offline