如何修复无效的对象表名称?
SELECT Proc_Code
FROM ClinicProcedures
WHERE Proc_Code NOT IN (SELECT Proc_Code FROM Patient)
答案 0 :(得分:0)
Make sure you are in the correct database that has those objects. Most likely, you are in the master database.
Lookup the "USE {database}" command in the documentation. Alternatively, you can use the full naming convention of objects, and execute in any database:
SELECT Proc_Code FROM MyDatabase.myschema.ClinicProcedures WHERE Proc_Code NOT IN (SELECT Proc_Code FROM MyDatabase.myschema.Patient);
答案 1 :(得分:0)
此错误通常是由于数据库上下文不匹配而发生的。用户打开SSMS时,不会注意到默认数据库设置为master。您只需要将数据库上下文更改为当前对象的数据库即可。