When I’m trying to create a role then I receive the error “role exists” and I have to deleted first and repeat the process.
- How may I check if a role exists in my sql database in sql server 2008 r2?
- Is there any
sys.table
to search for it?
When I’m trying to create a role then I receive the error “role exists” and I have to deleted first and repeat the process.
sys.table
to search for it?use sys.database_principals view:
select * from sys.database_principals where name = @Role_Name and type = 'R'
it's also possible to use database_principal_id:
select database_principal_id(@Role_Name)