Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot find the object because it does not exist or you do not have permissions. Error in SQL Server

Tags:

sql-server

I have a database and have a Sql script to add some fields to a table called "Products" in the database.

But when i am executing this script, I am getting the following error:

Cannot find the object "Products" because it does not exist or you do not have permissions 

Why is the error occurring and what should I do to resolve it?

like image 351
Embedd_0913 Avatar asked Jul 16 '09 10:07

Embedd_0913


People also ask

How do you fix the Execute permission was denied on the object?

This can be done from SQL Management Studio or directly by SQL query: - Right click on the specific stored procedure, select Properties, go to Permissions page. Search for 'ComXClient' user and then select checkbox in Execute line and Grant column.

What is references permission SQL Server?

The REFERENCES permission on a table is needed to create a FOREIGN KEY constraint that references that table. The REFERENCES permission is needed on an object to create a FUNCTION or VIEW with the WITH SCHEMABINDING clause that references that object.

What permissions are needed to truncate a table in SQL Server?

Permissions. The minimum permission required is ALTER on table_name. TRUNCATE TABLE permissions default to the table owner, members of the sysadmin fixed server role, and the db_owner and db_ddladmin fixed database roles, and are not transferable.


1 Answers

I found a reason why this would happen. The user had the appropriate permissions, but the stored procedure included a TRUNCATE statement:

TRUNCATE TableName 

Since TRUNCATE deletes items without logging, you (apparently) need elevated permissions to execute a stored procedure that contains it. We changed the statement to:

DELETE FROM TableName 

...and the error went away!

like image 106
Kevin Moloney Avatar answered Oct 12 '22 11:10

Kevin Moloney