The EXECUTE permission was denied on the object 'xxxxxxx', database 'zzzzzzz', schema 'dbo'

匿名 (未验证) 提交于 2019-12-03 02:30:02

问题:

I'm having problems executing a function.

Here's what I did:

  1. Create a function using SQL Server Management Studio. It was successfully created.
  2. I then tried executing the newly created function and here's what I get:

The EXECUTE permission was denied on the object 'xxxxxxx', database 'zzzzzzz', schema 'dbo'.

回答1:

Sounds like you need to grant the execute permission to the user (or a group that they a part of) for the stored procedure in question.

For example, you could grant access thus:

USE zzzzzzz; GRANT EXEC ON dbo.xxxxxxx TO PUBLIC 


回答2:

Best solution that i found is create a new database role i.e.

CREATE ROLE db_executor; 

and then grant that role exec permission.

GRANT EXECUTE TO db_executor; 

Now when you go to the properties of the user and go to User Mapping and select the database where you have added new role,now new role will be visible in the Database role membership for: section

For more detail read full article



回答3:

In Sql Server:

just go to security->schema->dbo.

Double click dbo, then click on permission tab->(blue font)view database permission and feel free to scroll for required fields like "execute".Help yourself to choose usinggrantor deny controls. Hope this will help:)



回答4:

you need to run something like this

GRANT Execute ON [dbo].fnc_whatEver TO [domain\user] 


回答5:

This will work if you are trying to Grant permission to Users or roles.

Using Microsoft SQL Server Management Studio:

  1. Go to: Databases
  2. Right click on dbo.my_database
  3. Choose: Properties
  4. On the left side panel, click on: Permissions
  5. Select the User or Role and in the Name Panel
  6. Find Execute in in permissions and checkmark: Grant,With Grant, or Deny


回答6:

You don't have the right to execute it, although you have enough permissions to create it.

For more information, see GRANT Object Permissions (Transact-SQL)



回答7:

Giving such permission can be dangerous, especially if your web application uses that same username.

Now the web user (and the whole world wide web) also has the permission to create and drop objects within your database. Think SQL Injection!

I recommend granting Execute privileges only to the specific user on the given object as follows:

grant execute on storedProcedureNameNoquotes to myusernameNoquotes 

Now the user myusernameNoquotes can execute procedure storedProcedureNameNoquotes without other unnecessary permissions to your valuable data.



回答8:

If you have issues like the question ask above regarding the exception thrown when the solution is executed, the problem is permission, not properly granted to the users of that group to access the database/stored procedure. All you need do is to do something like what i have below, replacing mine with your database name, stored procedures (function)and the type of permission or role or who you are granting the access to.

USE [StableEmployee] GO GRANT EXEC ON dbo.GetAllEmployees TO PUBLIC 

/****** Object: StoredProcedure [dbo].[GetAllEmployees] Script Date: 01/27/2016 16:27:27 ******/

SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO ALTER procedure [dbo].[GetAllEmployees] as Begin Select EmployeeId, Name, Gender, City, DepartmentId From tblEmployee  End 


回答9:

I have faced the same problem and I solved as give db_owner permission too to the Database user.



回答10:

You can give everybody execute permission:

GRANT Execute on [dbo].your_object to [public] 

"Public" is the default database role that all users are a member of.



回答11:

If you make this user especial for a specific database, then maybe you do not set it as db_owner in "user mapping" of properties



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!