I have a (SS2005) database with a user named MY_APPLICATION_USER. I'm trying to create a role in that database named MY_APPLICATION_USER.
When I try to do that using this script:
/****** Object: Role [MY_APPLICATION_USER] ******/
CREATE ROLE [MY_APPLICATION_USER] AUTHORIZATION [dbo]
GO
I get the error message:
Msg 15023, Level 16, State 1, Line 2
User, group, or role 'MY_APPLICATION_USER' already exists in the current database.
Does SQL Server have a restriction where it is not allowed to have a user and a role with the same name? I googled various ways of asking that question and did not find anything which addresses this, but it's certainly possible that I missed something.
Best Answer
No, you cannot have a User and a Role with the same name. These objects are all stored and referenced in
sys.database_principals
, requiring they are unique.sys.database_principals MSDN Reference
Quoted from the
name
parameter: