When I execute this SQL:
USE ASPState
GO
IF NOT EXISTS(SELECT * FROM sys.sysusers WHERE NAME = 'R2Server\AAOUser')
CREATE USER [R2Server\AAOUser] FOR LOGIN [R2Server\AAOUser];
GO
I get the following error:
The login already has an account under a different user name.
How do I know what this different user name is for my login account?
Best Answer
This means that the login [R2Server\AAOUser] is already mapped to a user in that database. Or, in other words, another database user is using this login. You can see what database user is using your login with the following query:
PS: a version of the script that doesn't use the compatibility views: