SQL Server Truncate Table Error Cannot find the object

In SQL Server, to clear the full content of a table, the fastest way is to run a Truncate Table query. The Truncate is different from the Delete From query because it empties all the lines in the table without a Where clause, it’s a DDL SQL operation (Database Definition Langage). In reality more access is needed to perform a Truncate on a table to avoid errors.

SQL Server Truncate table error “Cannot find the object “YourTable” because it does not exist or you do not have permissions.”

Indeed you get this error message if you don’t have the right level of permission.

Executing the query “TRUNCATE TABLE dbo.YourTable;” failed with the following error: “Cannot find the object “YourTable” because it does not exist or you do not have permissions.”
Possible failure reasons: Problems with the query, “ResultSet” property not set correctly, parameters not set correctly, or connection not established correctly.

Fisrt and best solution is to grant ALTER to this table

GRANT ALTER ON [dbo].[YourTable] TO [SQLUser]
GO

Second solution is to use a DELETE instead of the TRUNCATE

If the DELETE performance allows to use it then use a statement like this one instead:

DELETE FROM [dbo].[YourTable];

We have seen how to avoid the SQL Server Truncate Table Error Cannot find the object, check out other common SQL Server Errors.

Be the first to comment

Leave a Reply