Is there a way I can run a script to find the correct schema that is associated with a certain individual? The exact scenario I'm thinking of is in a Sandbox database. So generally speaking, I know the format of the users, but it doesn't always line up SYSTEM_USER = Schema. Apparently, there is a set definition that should be followed, but it is not always followed.
So basically, if the user's name is something like 'JusticeLeague\SuperMan' but the Schema is only 'SuperMan' for some reason, I'd like to be able to get the actual schema.
Is this possible at all? Any hints?
This seems to work, assuming the only difference is using the domain or not using the domain. Can anyone think of a better way? One that gets the exact value, regardless of how it's typed, perhaps?
Thanks for any thoughts
"But thanks be to God, which giveth us the victory through our Lord Jesus Christ." 1 Corinthians 15:57
So basically, if the user's name is something like 'JusticeLeague\SuperMan' but the Schema is only 'SuperMan' for some reason, I'd like to be able to get the actual schema.
Is this possible at all? Any hints?
This seems to work, assuming the only difference is using the domain or not using the domain. Can anyone think of a better way? One that gets the exact value, regardless of how it's typed, perhaps?
Code:
SELECT SYSTEM_USER
SELECT s.*
FROM Sandbox.sys.schemas s
WHERE REPLACE(s.name,'JusticeLeague\','') = REPLACE(SYSTEM_USER,'JusticeLeague\','')
Thanks for any thoughts
"But thanks be to God, which giveth us the victory through our Lord Jesus Christ." 1 Corinthians 15:57