Skip to main content

ESP - Delete User

/*

Delete users from ESP which do not exist in Active Directory
Created By	: Steve Ling 2024/03/07

*/

Declare @username nvarchar(30), @UID int, @UPD int

Set @username = 'Steve.Ling'
Set @UPD		= 0 --1 to delete 0 to select

--- No Changes below here

Set @UID = (select ID from infuser where name = @username)

if @UPD <> 1
Begin
	select * from infTaskbutton where usernameID = @UID 
	select * from infUserMembership where memberID = @UID
	select * from infuser where name = @username
End

if @UPD = 1
Begin
	delete from infTaskbutton where usernameID = @UID 
	delete from infUserMembership where memberID = @UID
	delete from infuser where name = @username
End