Long back I was fond of goto statements, actually my fav language was GWBASIC and goto is inevitable part of it. You have to use goto for program controls and there was no other way of doing it. I never felt any thing bad with that and for me it was really easy to figure out how the program is flowing using the goto statement. Later I read a lot about the problems we can face only because of goto statement (http://en.wikipedia.org/wiki/Goto#Criticism_of_goto_usage).
If you have used goto or similar coding style, you will understand why it is criticised.
Anyways, let me come to SQL Server, why I was discussing goto statements here is only because of aliases, you can alias an user to a user in SQL and after that keep guessing whats going on. If there are several databases and login is user in most of them and you see that login aliased, you need to check to what user it is aliased and what permission it is inheriting from the original user (to which it is aliased). So, you are stuck in a loop. Actually, aliases are there just as a backward compatibility (coming from SQL Server 6.5 and earlier).
I personally avoid using this, and will never recommend it. Recently I got a call from user to check if she has permissions in a particular database, checking with GUI, I said no, but later realised that she has her user aliased to DBO, I called her back and described her how I missed that.
To know which user is aliased to which user in a database, run ->
select a.name 'User', b.name 'Aliased To' from sysusers a, sysusers b
where a.altuid = b.uid and a.isaliased = 1
Sunday, October 11, 2009
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment