tt-615680 (11/27/2015)
Thank you for your reply, I'm running the following sql permission query which works fine on all other servers, the only difference is that a few of the databases have on the server which I'm running the query from have "-" in their names e.g. "database-name"EXEC sp_MSforeachdb
'USE ?
insert into #temp
select DB_NAME() AS DatabaseName,
mp.type AS [AccountType],
mp.name as Database_user,
rp.name as DatabaseRole,
rp.type_desc AS TypeDesc
from sys.database_role_members drm
join sys.database_principals rp on (drm.role_principal_id = rp.principal_id)
join sys.database_principals mp on (drm.member_principal_id = mp.principal_id)
order by database_user
'
select
DatabaseName,
AccountType,
Database_user,
DatabaseRole,
TypeDesc
from #temp
When running the following query I'm able to get the database result without any issues:
select *
from sys.databases
where name = 'database-name'
Thank you!
Databases with a - in the name need to be surrounded with square brackets [], [database-name].