Post Pacific  

Go Back   Post Pacific > Восстановленный архив > Темы без сохранившегося раздела
FAQ Community Calendar Today's Posts Search

Notices

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
Old 09.04.2007, 15:10   #1
m4rk
Архивный участник
 
Join Date: Jan 2006
Posts: 607
Default [SHARE][MSSQL QUERY] Find non existing accounts with existing chars

Abstract: I found this problem while deleting unused and banned accounts. I realized there were some (few but some after all) accounts that were deleted even if they had characters on them. So I built this query to get the ID of those accounts. Hope this saves you some time if you need this.

Check the second post by Sauron

This one will just print the account_id
Code:
--declare variables
declare @max int
declare @current int
declare @exist int

--set variables
USE LIN2WORLD
SET @max = (SELECT TOP 1 account_id from user_Data	ORDER BY account_id DESC)
SET @current = (SELECT TOP 1 account_id from user_Data WHERE account_id!= -1 ORDER BY account_id ASC)

--loop condition
WHILE @current<@max

BEGIN

USE LIN2DB
SET @exist = (SELECT COUNT(*) FROM user_account WHERE uid=@current)
IF @exist = 0 
PRINT @current

USE LIN2WORLD	
SET @current = (SELECT TOP 1 account_id from user_Data WHERE account_id>@current ORDER BY account_id ASC)

END

This one will return the SELECT * FROM user_data WHERE account_id= the non existing account in LIN2DB
Code:
--declare variables
declare @max int
declare @current int
declare @exist int

--set variables
USE LIN2WORLD
SET @max = (SELECT TOP 1 account_id from user_Data	ORDER BY account_id DESC)
SET @current = (SELECT TOP 1 account_id from user_Data WHERE account_id!= -1 ORDER BY account_id ASC)

--loop condition
WHILE @current<@max

BEGIN

USE LIN2DB
SET @exist = (SELECT COUNT(*) FROM user_account WHERE uid=@current)
IF @exist = 0 
BEGIN
USE LIN2WORLD 
SELECT * FROM lin2world.dbo.user_data WHERE account_id=@current
END

USE LIN2WORLD	
SET @current = (SELECT TOP 1 account_id from user_Data WHERE account_id>@current ORDER BY account_id ASC)

END
m4rk 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 15:52.