USE ReportServer
GO
-- Get user ID
DECLARE @OldUser NVARCHAR(36) = (
SELECT UserId
FROM dbo.Users
WHERE userName = '<domain_name,,domain>\<old_user,,windows_user>'
)
DECLARE @NewUser NVARCHAR(36) = (
SELECT UserId
FROM dbo.Users
WHERE userName = '<domain_name,,domain>\<new_user,,windows_user>'
)
-- Validate User
IF EXISTS (
SELECT *
FROM dbo.Subscriptions
WHERE [OwnerID] = @NewUser
)
BEGIN
-- Update to new user
UPDATE s
SET OwnerID = @NewUser
FROM dbo.Subscriptions AS s
WHERE [OwnerID] = @OldUser
END
GO