Skip to main content

Move Inbox Documents between Users

The below SQL query can be used to either move documents from user to another, or to update a current user in the case of a username or domain change.

Use with care!! DECLARE @oldUser NVARCHAR(50) = 'domain\olduser'; DECLARE @newUser NVARCHAR(50) = 'domain\newuser';

-- To find affected records SELECT * FROM userdocs WHERE ActionResponse = -1 AND deleted 1 AND IdentityName LIKE '%' + @oldUser + '%'

-- Move them to the new user BEGIN TRAN;

UPDATE userdocs SET IdentityName = @newUser WHERE ActionResponse = -1 AND deleted 1 AND IdentityName LIKE '%' + @oldUser + '%' ROLLBACK TRAN;

-- COMMIT TRAN; when doing this for real