SQL Server 2005/2008 - Why is the sys.sysobjects view available to users without the schema name?

前端 未结 2 1500
清歌不尽
清歌不尽 2021-01-15 04:23

I\'ve noticed some strange behavior in SQL Server Express 2008, and I\'ve been trying to track down the cause. When you create a new database, you are able to access the sys

相关标签:
2条回答
  • 2021-01-15 04:37

    IIRC, SQL Server looks for objects in the following order:

    1. sys schema
    2. users schema (This is different for Stored Procs - it will look in the stroed procs schema rather than the users schema.
    3. dbo schema
    0 讨论(0)
  • 2021-01-15 04:38

    It's a special case. These are backward compatibility views.

    In SQL 2000 it was not necessary to use the sys schema so they made it so that existing code would still work for these objects.

    These have all been replaced with new system views and functions and are slated to be removed in a future version of SQL Server so should be avoided where possible (see the topic "Mapping System Tables to System Views" in BOL for details). Though there are some circumstances in which they are still required.

    0 讨论(0)
提交回复
热议问题