Post Pacific  

Go Back   Post Pacific > Lineage 2 > Lineage 2 Server Modifications ONLY!
FAQ Community Calendar Today's Posts Search

Notices

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
Old 25.02.2006, 01:39   #1
nucer
Архивный участник
 
Join Date: May 2005
Posts: 117
Default [small share]Script for clear database

This stored procedure will clear unused characters with their items, skills and quests.
Code:
CREATE PROCEDURE [DBO].[lin_DeleteOldChars]  
@days INT
AS  
SET NOCOUNT ON  
  
DECLARE @ToDeleteCharacter CURSOR  
DECLARE @char_id INT  
SET @ToDeleteCharacter = CURSOR FAST_FORWARD FOR
  
SELECT char_id  FROM user_data  WHERE account_id <= 0  OR ( logout>login AND logout<GETDATE()-@days)
OPEN @ToDeleteCharacter  
FETCH FROM @ToDeleteCharacter INTO @char_id  
  
WHILE @@FETCH_STATUS = 0  
BEGIN  
 DELETE FROM user_item WHERE char_id=@char_id
 DELETE FROM user_skill WHERE char_id=@char_id
 DELETE FROM Quest WHERE char_id=@char_id

 FETCH NEXT FROM @ToDeleteCharacter INTO @char_id  
END  
  
CLOSE @ToDeleteCharacter   
DEALLOCATE @ToDeleteCharacter

DELETE  FROM user_data  WHERE account_id <= 0  OR ( logout>login AND logout<GETDATE()-@days)
GO
nucer is offline  
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 21:50.