Error
Error Code:
267
SQL Server Object Not Found
Description
SQL Server Error 267 indicates that the database engine cannot locate a specified object. This typically occurs when a query or stored procedure references a table, view, or other database object that doesn't exist or is inaccessible.
Error Message
Object '%.*ls' cannot be found.
Known Causes
4 known causesObject Does Not Exist
The object specified in the query, such as a table or view, has not been created in the database.
Incorrect Object Name
The object name in the query contains a typo or is not cased correctly (if the database is case-sensitive).
Insufficient Permissions
The user executing the query does not have the necessary permissions (e.g., SELECT, EXECUTE) to access the specified object.
Object in Different Schema
The object exists but resides in a different schema than the one assumed by the query; the schema isn't specified in the query.
Solutions
4 solutions available1. Verify Object Name and Schema easy
Ensure the object name and its schema are correctly specified in the query.
1
Examine the SQL statement that is causing the error. Pay close attention to the exact spelling of the object name (table, view, stored procedure, function, etc.) and the schema it belongs to.
SELECT * FROM NonExistentSchema.MyTable;
2
If the object exists, confirm it's in the schema you're referencing. If it's in a different schema, update your query to include the correct schema name.
SELECT * FROM CorrectSchema.MyTable;
3
If the object is in the default schema for the user executing the query (often 'dbo'), you might be able to omit the schema name, but it's generally good practice to be explicit.
SELECT * FROM MyTable; -- If MyTable is in the user's default schema
2. Check Database Context easy
Confirm that the query is being executed against the correct database.
1
Verify the database context in your SQL Server Management Studio (SSMS) query window. The dropdown menu at the top of the query window shows the currently selected database.
2
If you are using a script or application code, ensure that the connection string or the `USE` statement explicitly specifies the correct database.
USE MyDatabase;
GO
SELECT * FROM MyTable;
3
If the object resides in a different database than the one currently in context, either change the database context using the `USE` statement or fully qualify the object name with the database name.
SELECT * FROM OtherDatabase.dbo.MyTable;
3. Grant Necessary Permissions medium
Ensure the user executing the query has the required permissions on the object.
1
Identify the user or login that is executing the query causing the error.
2
Connect to SQL Server with an account that has sufficient privileges (e.g., `sysadmin` or `db_owner`).
3
Grant the necessary permissions (e.g., `SELECT`, `INSERT`, `UPDATE`, `DELETE`, `EXECUTE`) on the object to the user or a role that the user is a member of.
GRANT SELECT ON dbo.MyTable TO YourUser;
GO
GRANT EXECUTE ON dbo.MyStoredProcedure TO YourUser;
GO
4
If the user is a member of a database role, grant permissions to the role instead of the individual user for easier management.
ALTER ROLE db_datareader ADD MEMBER YourUser;
GO
4. Recreate or Verify Object Existence medium
Confirm the object actually exists and is not corrupted or missing.
1
Query the system catalog views to confirm the object's existence and its properties.
SELECT OBJECT_ID('dbo.MyTable', 'U') AS TableObjectID;
SELECT OBJECT_ID('dbo.MyStoredProcedure', 'P') AS SPObjectID;
2
If the `OBJECT_ID` returns NULL, the object does not exist in the specified schema and database. You will need to create it or restore it.
3
If the object is a stored procedure, function, or view, check its definition for syntax errors or dependencies on other missing objects.
EXEC sp_helptext 'dbo.MyView';
EXEC sp_helptext 'dbo.MyFunction';
4
If the object definition appears correct but still causes issues, consider dropping and recreating the object (after backing up its definition if necessary). This can resolve issues with metadata corruption.
DROP PROCEDURE dbo.MyStoredProcedure;
GO
-- Recreate the stored procedure with its correct definition