I'm using this stored procedure called OBJECT_DEFINITION
as was suggested. It's helping me wrap my head around the SQL Server system. However, there is one area that I can't yet figure out. On this one table sys.objects
, you'll see it pulls from itself.
1> SELECT OBJECT_DEFINITION(OBJECT_ID('sys.objects'))
2> GO
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
CREATE VIEW sys.objects AS
SELECT name,
.. stuff.
FROM sys.objects$
Now I'm totally lost how is sys.objects
selecting from sys.objects$
what is sys.objects$
. Thinking there may be a table of the same name, I first tried to create a table and a view by the same name, but I can't do that. I get (f
is the name I picked). You can't do this in any database I've ever used.
Msg 2714, Level 16, State 3, Server x230, Procedure f, Line 1
There is already an object named 'f' in the database.
Microsoft docs sys.objects
only as a Catalog View, it's not listed as a Base Table
The counterpart Catalog View, sys.system_objects
pulls from the Base Table sys.sysschobjs
, and OBJECT_DEFINITION
clearly shows that.
My guess is that the SQL here isn't the actually SQL the view is executing, but some kind of comment or description on it: meta-data of sort, and that it's bugged. But, I could be totally off.