Disconnect User Procedure

Junior Spellweaver
Joined
Jun 5, 2006
Messages
133
Reaction score
0
This is to be used with the recently released disconnect user program made by gregg.

Code:
alter Procedure DisconnectUsers
as
declare @struserid varchar(21), @old varchar(21),@count int, @count2 int
declare @row int

select @count = count(*) from knight_account.dbo.currentuser where strcharid in (select struserid from known_dupe)
while @count > 0
begin


DECLARE Backup_Cursor CURSOR FOR                                       
	SELECT distinct strcharid from knight_account.dbo.currentuser
where strcharid not in(select struserid from known_dupe)

	OPEN Backup_Cursor
	FETCH NEXT FROM Backup_Cursor INTO @strUserID

WHILE @@FETCH_STATUS = 0
BEGIN
	SELECT @row = count(*) 
	FROM USERDATA
	WHERE strUserID = @strUserID
select @count2 = count(*) from disconnect_user where userid = @struserid
	IF @row > 0
	BEGIN
	if @count2 < 1
begin
		insert into disconnect_user values (@struserid)
end
	END

	FETCH NEXT FROM Backup_Cursor INTO @strUserID
END

CLOSE Backup_Cursor
DEALLOCATE Backup_Cursor


end

You can use any table name you want instead of disconnect_user
you also may need to edit it to be customized for your server. The duper table name and whatnot. This is my contribution.
 
woops the procedure should be
Code:
alter Procedure DisconnectUsers
as
declare @struserid varchar(21), @old varchar(21),@count int, @count2 int
declare @row int

select @count = count(*) from knight_account.dbo.currentuser where strcharid in (select struserid from known_dupe)
while @count > 0
begin


DECLARE Backup_Cursor CURSOR FOR                                       
	SELECT distinct strcharid from knight_account.dbo.currentuser
where strcharid in (select struserid from known_dupe)

	OPEN Backup_Cursor
	FETCH NEXT FROM Backup_Cursor INTO @strUserID

WHILE @@FETCH_STATUS = 0
BEGIN
	SELECT @row = count(*) 
	FROM USERDATA
	WHERE strUserID = @strUserID
select @count2 = count(*) from disconnect_user where userid = @struserid
	IF @row > 0
	BEGIN
	if @count2 < 1
begin
		insert into disconnect_user values (@struserid)
end
	END

	FETCH NEXT FROM Backup_Cursor INTO @strUserID
END

CLOSE Backup_Cursor
DEALLOCATE Backup_Cursor


end
 
this procedure will dc anyone thats in the disconnect_user table? so you have to manually put there names into that table or what?
 
Re: [Share] Disconnect User Procedure

Should actually be CREATE PROCEDURE, instead of ALTER PROCEDURE, as they won't have the procedure to ALTER in the first place.
 
Back