Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

SQL Server Error 370 Unknown Object Name Fix

· 5 min read · Home Tech

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

SQL Server Error 370, "Unknown object name," occurs when a query references a table, view, stored procedure, or other database object that does not exist in the current context. This is typically caused by typos, incorrect database or schema names, or permissions issues. The fix involves verifying object existence, checking scope, and ensuring proper authentication. No tools beyond SQL Server Management Studio (SSMS) or a compatible query tool are required.

What You'll Need

  • Access to SQL Server Management Studio (SSMS) or another SQL client (like Azure Data Studio or sqlcmd)
  • Valid login credentials with at least VIEW DEFINITION permission on the target database
  • The exact name of the object you're trying to reference
  • Knowledge of the database and schema context you're working in

Step-by-Step

  1. Confirm the database you're connected to is the correct one. Run SELECT DB_NAME() to see the current database context. If it's wrong, use USE [YourDatabaseName] to switch.
  2. Verify the object exists by querying the system catalog. Run SELECT * FROM sys.objects WHERE name = 'YourObjectName'. Replace YourObjectName with the exact name from your error message. If no rows return, the object does not exist in this database.
  3. Check the schema name. Objects are scoped to schemas (e.g., dbo.TableName). Run SELECT schema_name(schema_id) as SchemaName, name as ObjectName FROM sys.objects WHERE name = 'YourObjectName'. If the object appears but is under a different schema (like hr or sales), qualify the reference in your query with the schema: SELECT * FROM hr.YourTableName.
  4. Look for case sensitivity issues. If your server uses a case-sensitive collation (e.g., SQL_Latin1_General_CP1_CS_AS), the object name must match exactly. Compare the name using SELECT name FROM sys.objects WHERE name COLLATE SQL_Latin1_General_CP1_CS_AS = 'YourObjectName'.
  5. Check if the object was recently created or renamed. If you just created the object, refresh the Object Explorer in SSMS by right-clicking the database and selecting Refresh. If it was renamed, update your query to use the new name.
  6. Ensure you're not referencing a temporary table outside its scope. Local temporary tables (prefixed with #) are only visible in the session they were created in. If your query runs in a different context (like a stored procedure or job), the table won't exist.
  7. Test with a simple SELECT. Instead of running a complex query, try SELECT TOP 1 * FROM YourSchema.YourTable to isolate whether the object name is the issue.
  8. Verify permissions. Run SELECT permission_name, state_desc FROM sys.database_permissions WHERE major_id = OBJECT_ID('YourSchema.YourTable'). If you lack SELECT, VIEW DEFINITION, or other required permissions, contact your database administrator.

Common Mistakes

  • Assuming the default schema is always dbo. Many databases use custom schemas (e.g., app, audit), and failing to qualify the schema leads to this error.
  • Typing the object name incorrectly. Even a single missing letter (e.g., Customer vs Custumer) triggers the error. Always copy and paste names from Object Explorer.
  • Running queries against the wrong database. Connecting to master or a test database instead of the production one is a frequent cause.
  • Using a synonym or alias that was dropped or misconfigured. Check sys.synonyms if you're referencing a synonym.
  • Assuming case-insensitive matching applies everywhere. Some SQL Server instances use case-sensitive collations, especially in production environments.

Tips

  • Use SSMS Object Explorer to drag and drop object names into your query window — this ensures exact spelling and schema qualification.
  • Always prefix object names with schema (e.g., dbo.TableName) even if it's the default. It prevents ambiguity and improves performance.
  • Use IntelliSense in SSMS to autocomplete object names. If the object doesn't appear in the dropdown, it likely doesn't exist or you lack permissions.
  • When scripting objects, always include the schema name in the CREATE statement. If you script from Object Explorer, SSMS includes it by default.
  • Use sp_help 'YourObjectName' to get full details about an object's schema, type, and column definitions.
  • For complex environments, maintain a naming convention (e.g., tbl_ for tables, sp_ for stored procedures) to reduce confusion.

Troubleshooting

If the above steps do not resolve the error, proceed systematically:

  1. Restart SSMS and reconnect. A stale connection or cached metadata can cause false negatives.
  2. Check SQL Server error logs. Open SSMS > Management > SQL Server Logs. Look for warnings about failed object access or database attachment issues.
  3. Verify the database is online. Run SELECT name, state_desc FROM sys.databases WHERE name = 'YourDatabaseName'. If state is RECOVERING or SUSPECT, the database is not accessible.
  4. Test from a different client or machine. If another user can access the object, the issue is likely with your login or permissions.
  5. Temporarily grant sysadmin role to your login (if allowed) to test if permissions are the root cause. If it works, then revoke and grant only necessary permissions.
  6. Check for database replication or mirroring delays. If this is a mirrored or replicated database, the object might not yet be synchronized.
  7. If you're using a linked server, ensure the remote object exists and the linked server login has rights. Test with SELECT * FROM [LinkedServerName].[DatabaseName].[SchemaName].[TableName].
  8. If the object was dropped and recreated, clear the query plan cache with DBCC FREEPROCCACHE — though this is rare, cached execution plans can reference non-existent objects.

Frequently Asked Questions

Can this error occur if the object exists but I don't have permissions?

Yes. If you lack VIEW DEFINITION or SELECT permissions, SQL Server may return this error instead of a permissions-specific one, especially in older versions or when the object is referenced in a view or stored procedure you don't own.

Why does the object appear in Object Explorer but my query still fails?

This happens when you're connected to the wrong database, the object is in a different schema, or you're in a different user context. Always use USE [Database] and fully qualify with schema before the object name.

Does this error mean the object was deleted?

Not necessarily. The object may have been renamed, moved to another schema, or the database context changed. Always verify existence using sys.objects before assuming deletion.

Can I fix this by restarting SQL Server?

Restarting SQL Server will not fix this error unless the instance was in a corrupted state — which is extremely rare. This error is almost always due to naming, scope, or permission issues, not server health.

What if I'm using a stored procedure and get this error inside it?

Stored procedures inherit the caller's context. Ensure the procedure references objects using fully qualified names (schema.object) and that the caller has permissions on all referenced objects. Avoid using local temporary tables inside procedures if they're referenced outside the procedure scope.

Can this error appear in SQL Server Agent jobs?

Yes. Jobs run under the SQL Server Agent service account, which may not have access to the object or database. Ensure the job step specifies the correct database and the service account has the required permissions.