• bitbucket-25253 (11/19/2009)


    Having recently gotten my brains beat out, my integrity questioned, my intelligence derided and other wise vilified (Refer to the QOD 11/17/2009 forum). I am greatly surprised that the little bitty nitpickers are not raging here in this forum, perhaps it is because they do not intimately know enough about SQL Server or since they got the message they so dearly love to see, that is "You got it right".

    But let me point out a technicality: The question asked which of these views would you query. The correct answer as given is sysobjects.

    Now for the sorry bit of fact the displayed item: sysobjects is a SYSTEM TABLE

    The VIEW is sys.sysobjects. Which of course contains essentially the same data as does the system table. To be more specific it is defined as a CATALOG VIEW, but a view nevertheless.

    If you are going to pick nits, make sure you get your facts right. 😛

    In SQL Server 2000 and older versions, sysobjects was indeed a system table. But as of SQL Server 2005, system tables are no longer exposed. They have been replaced by system views, of which sys.objects (that is, the view named objects in the schema named sys) is an example.

    To preserve compatibility with older versions, a second set of views, the so-called compatibility views, were introduced. One of those views is sys.sysobjects. And to preserve full compatibility, SQL Server will find this view even if you omit the schema name and shorten it to just sysobjects.

    So, unless you assumed the question to be about SQL Server 2000 or before, you picked the wrong nit. For in all current versions of SQL Server, sysobjects is indeed a view, not a table.

    The true nitpicker though, would have complained about something else - and that is that the real true answer is not included. Books Online includes a note with all compatibility views that these will be removed in a future version of SQL Server, and that the current SQL Server system views should be used instead. So the only really correct answer would have been to query the sys.objects view.


    Hugo Kornelis, SQL Server/Data Platform MVP (2006-2016)
    Visit my SQL Server blog: https://sqlserverfast.com/blog/
    SQL Server Execution Plan Reference: https://sqlserverfast.com/epr/