Friday, March 13, 2009

SQL 2005 execute as

I need to login as user when i want to test their permission against the database object and most of time I forgot/ never record user password and need request password from them

with SQL 2005, I don't need relogin, I can do this as below

login as sa
execute as user='user'
--select from login table with "user" permission
select * from login

revert
--revert back to sa

No comments: