tags:

views:

72

answers:

2

I have a couple of questions.

1) Why cannot we see system tables (like sysobjects) under Master/Model/MSBD etc.? But we

can query. Are we basically querying the views, because as they are the main tables that

holds a value able informations?

Like "SELECT * FROM sysobjects". are we basically querying some views?

2) Why cannot we add triggers to system tables?

Thanks in advance

+2  A: 

Hi

SQL Server 2008 system tables (http://msdn.microsoft.com/en-us/library/ms179932.aspx) have been implemented as read-only views. One cannot directly work with the data in these system tables. You can access SQL Server metadata using catalog views. Do check this link http://msdn.microsoft.com/en-us/library/ms174365.aspx

It is possible to create triggers on system tables but it is generally not recommended. Please check this http://www.sql-server-performance.com/faq/trigger_system_table_p1.aspx

cheers

Andriyev
+1  A: 

Since SQL 2005 the catalog views are implemented as views declared in the Resource Database (mssqlsystemresource). Due to some special magic they appear to exist in every database.

You can always use the execution plan to see from what actual tables do these views fetch data from. The underlying tables can be accessed when you are connected with a DAC connection. Modifying the system tables in any way will mark the database and an message will be logged every time the database starts up. Modified databases are not supported by MS, so if something goes wrong you cannot ask for support.

Remus Rusanu