Imitating ownership possible?

Imitating ownership possible?

am 20.12.2007 15:53:05 von google.1.jvmail

In order to run SQL queries without having to fully qualify ownership,
I know it's necessary to either give ownership to the DBO or log in to
the server as the object owner. The goal I have is to allow entry of a
SQL statement having without logging in as that user and without
having to fully qualify ownership. I know we can USE a different
database easily, so is it also possible to use a different user in
Query Analyzer as the default? That would make life so much easier
than reconnecting as a different user.

Thanks.

J

Re: Imitating ownership possible?

am 20.12.2007 16:22:20 von Plamen Ratchev

In SQL Server 2000 you could use the SETUSER command
(http://msdn2.microsoft.com/en-us/library/aa259240(SQL.80).a spx) to
impersonate the user context for a SQL user account. However, this can only
be used by a sysadmin or db_owner and could not be used for Windows
accounts. In SQL Server 2005 you can use the EXECUTE AS clause to change the
execution context.

Here is a good article about EXECUTE AS:
http://blogs.msdn.com/sqlserverstorageengine/archive/2006/06 /21/642061.aspx

HTH,

Plamen Ratchev
http://www.SQLStudio.com

Re: Imitating ownership possible?

am 20.12.2007 16:33:22 von google.1.jvmail

Awesome. Thanks for the quick response. I've got a lot of experience
in SQL in other languages, and some in SQL Server, but all the little
tricks of the trade I'm still short on.

Thanks again.

J