SQL Server Error 267 occurs when the database engine cannot find a specific object—such as a table, view, or stored procedure—that a query or script is attempting to reference. To fix this, you must verify that the object exists in the current database context, ensure you are using the correct schema prefix, and confirm that the user account has the necessary permissions to access the object.
What You'll Need
- SQL Server Management Studio (SSMS) or another compatible SQL query tool.
- Administrative or
db_ownerpermissions for the database in question. - The exact name of the object causing the error.
Step-by-Step
- Verify the Database Context
Ensure your query is running against the correct database. If you are using SSMS, check the available databases dropdown menu in the top-left toolbar. Alternatively, execute the commandUSE [DatabaseName];at the start of your script to force the context to the correct database. - Check for Object Existence
Confirm the object actually exists in the database. Expand the Tables, Views, or Programmability folders in the Object Explorer. If you cannot find the object manually, it may have been deleted or renamed. You can also run this query to search for the object:SELECT * FROM sys.objects WHERE name = 'YourObjectName'; - Apply the Full Schema Name
SQL Server may fail to find an object if it is not in the default schema (usuallydbo). Instead of referencing a table asTableName, use the two-part name:SchemaName.TableName(e.g.,Sales.Orders). This removes ambiguity and is the most common fix for Error 267. - Check for Typos and Case Sensitivity
Review the spelling of the object name. If your database uses a case-sensitive collation (e.g.,SQL_Latin1_General_CP1_CS_AS),MyTableandmytableare treated as different objects. Ensure the casing in your code matches the casing in the database exactly. - Verify User Permissions
If the object exists but the user does not haveSELECT,EXECUTE, orUPDATEpermissions, the engine may occasionally return an "object not found" or "access denied" style error. Grant the necessary permissions using:GRANT SELECT ON SchemaName.ObjectName TO UserName; - Refresh the IntelliSense Cache
If the error appears as a red underline in SSMS but the query actually runs successfully, it is a local cache issue. Go to Edit > IntelliSense > Refresh Local Cache or pressCtrl+Shift+R.
Common Mistakes
- Incorrect Database Selection: Running a script against the
masterdatabase instead of the user database where the table resides. - Assuming Default Schema: Assuming all objects are under
dbowhen they were actually created under a specific user schema. - Using Temporary Tables Incorrectly: Attempting to reference a local temporary table (starting with
#) from a different session or connection. - Ignoring Collation: Forgetting that a database is case-sensitive and using lowercase letters in the query for a capitalized object name.
Tips
- Always use two-part naming: Get into the habit of using
schema.objectto prevent context errors and improve query performance. - Use brackets for reserved words: If your object name contains spaces or is a reserved keyword (like
OrderorUser), wrap it in square brackets:[Order]. - Script the object: If you are unsure of the exact name or schema, right-click the object in Object Explorer and select Script As > CREATE To to see the exact definition.
Troubleshooting
If the steps above do not resolve the error, consider these deeper technical checks:
- Check for Synonyms: If you are referencing a synonym, the synonym itself might exist, but the base object it points to may have been deleted. Check
sys.synonymsto verify the target. - Review Dependency Chains: If the error occurs during the execution of a stored procedure, the procedure might be valid, but a table it references inside the code might be missing. Use
sp_dependsto check dependencies. - Cross-Database Queries: If the object is in a different database on the same server, you must use a three-part name:
DatabaseName.SchemaName.ObjectName. - Check for Dropped Objects in Transactions: If you are using
BEGIN TRANSACTION, ensure a previous single statement didn't accidentally drop the object before the current statement tried to access it.
Frequently Asked Questions
Why does the object show up in Object Explorer but I still get Error 267?
This is usually due to a schema mismatch. You are likely looking at the object in the Sales schema but calling it without the prefix, causing SQL Server to look for it in the dbo schema instead.
Can a lack of permissions cause this error?
Yes. In some security configurations, if a user does not have permission to see the metadata of an object, the system may report that the object cannot be found rather than explicitly stating "Access Denied" for security reasons.
Is this error related to the SQL Server version?
No, Error 267 is a logic and naming error related to the database schema and object existence; it is not caused by the specific version of SQL Server you are running.
How do I find which schema an object belongs to?
You can run SELECT schema_name(schema_id), name FROM sys.objects WHERE name = 'YourObjectName'; to identify the correct schema prefix.
Does refreshing the server help?
Restarting the SQL Server service will not fix this error because it is a problem with the code or the database structure, not a service glitch. Focus on the naming and permissions instead.