dbTalk Databases Forums  

Re: permissions problem when accessing stored procedures

comp.databases.ms-sqlserver comp.databases.ms-sqlserver


Discuss Re: permissions problem when accessing stored procedures in the comp.databases.ms-sqlserver forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Erland Sommarskog
 
Posts: n/a

Default Re: permissions problem when accessing stored procedures - 07-26-2003 , 02:49 PM






[posted and mailed, repondre en public, s'il vous plaît]

berthelot samuel (samuel.berthelot (AT) voila (DOT) fr) writes:
Quote:
I'm trying to execute a stored procedure from the sql analyser. When
I'm logged on my nt account, it works. But as soon as I try on another
account it gives me the message 'could not find procedure sp_name'
unless I specified my name before the name of the procedure when I
call exec. (I am the owner of the procedure).
Does anyone know how to solve this problem ?
If you is logged in as nisse, and you say

exec some_sp

SQL Server first checks if nisse owns an object with this name. If
there is no match, SQL Server checks if dbo, database owner, owns a
procedure with this name. If there is no match, SQL Server does not
check any further.

If some_sp is fact owned by kalle, then you need to say:

exec kalle.some_sp

Note that kalle must have granted rights to execute the procedure. (The
same applies for procedures owned by dbo.)

Three more things to note here:

o Logins are server-level, and user names are on database level. They
are often the same. You may be logged in as nisse, but in the database
you may be sara.
o A special case: if nisse owns the database, you are not nisse in that
database, but you are dbo.
o sa or any other user with sysadmin rights is always dbo.

--
Erland Sommarskog, SQL Server MVP, sommar (AT) algonet (DOT) se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp


Reply With Quote
  #2  
Old   
Dan Guzman
 
Posts: n/a

Default Re: permissions problem when accessing stored procedures - 07-27-2003 , 11:52 AM






When you reference an object without specifying the owner, SQL Server
will first use the object owned by your userid. If none exists, the
dbo-owned version is used. You'll get an error if neither exists.

You can determine your current database user name with SELECT USER. I
suspect you will get different results when you login under the
different accounts. There is normally a one-to-one relationship between
logins and database users so only the login that owns the proc can
reference it without owner qualification.

--
Hope this helps.

Dan Guzman
SQL Server MVP

-----------------------
SQL FAQ links (courtesy Neil Pike):

http://www.ntfaq.com/Articles/Index....partmentID=800
http://www.sqlserverfaq.com
http://www.mssqlserver.com/faq
-----------------------

"berthelot samuel" <samuel.berthelot (AT) voila (DOT) fr> wrote

Quote:
hi all,
I'm trying to execute a stored procedure from the sql analyser. When
I'm logged on my nt account, it works. But as soon as I try on another
account it gives me the message 'could not find procedure sp_name'
unless I specified my name before the name of the procedure when I
call exec. (I am the owner of the procedure).
Does anyone know how to solve this problem ?
thanx
Sam



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.