How to avoid the 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 database definition language SQL operation. In reality more access is needed to perform a Truncate on a table to avoid errors.
How to fix the SQL Server error : Cannot find the object YourTable because it does not exist or you do not have permissions?
Let’s assume the table exists in the database! Then it’s a privilege error. Indeed you get this error message if you don’t have the right level of permissions to see or to manipulate the table.
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.
First and recommended 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.