Business Intelligece Data Warehouse Consultants Atlanta

Knowledgy Consulting, LLC

"Atlanta's Premier Business Intelligence and Data Warehouse Consultants!"

Here's the view for the internal tables dynamic query. This is another query that references the invisible syspalnames system table. The syspalnames table is used often in joins of system views and describes databse object types.

CREATE 

VIEW sys.internal_tables

AS

   SELECT

      o.name,

      o.id AS object_id,

      CONVERT ( INTNULL ) AS principal_id,

      o.nsid AS schema_id,

      o.pid AS parent_object_id,

      o.type,

      n.name AS type_desc,

      o.created AS create_date,

      o.modified AS modify_date,

      CONVERT ( bit, 0 ) AS is_ms_shipped,

      CONVERT ( bit, 0 ) AS is_published,

      CONVERT ( bit, 0 ) AS is_schema_published,

      CONVERT ( TINYINTpar.depsubid ) AS internal_type,

      itt.name AS internal_type_desc,

      par.indepid AS parent_id,

      par.indepsubid AS parent_minor_id,

      lob.lobds AS lob_data_space_id,

      rfs.indepid AS filestream_data_space_id

   FROM

      sys.sysschobjs o

      LEFT JOIN sys.syspalnames n

      ON

         n.class = 'OBTY' AND

         n.value = o.type

      LEFT JOIN sys.syssingleobjrefs par

      ON

         par.depid = o.id AND

         par.class = 40 -- SRC_INTLTAB_PARENT

      LEFT JOIN sys.syspalvalues itt

      ON

         itt.class = 'ITTY' AND

         itt.value = par.depsubid

      LEFT JOIN sys.sysidxstats lob

      ON

         lob.id = o.id AND

         lob.indid <= 1

      LEFT JOIN sys.syssingleobjrefs rfs

      ON

         rfs.depid = o.id AND

         rfs.class = 42 AND

         rfs.depsubid = 0 -- SRC_OBJTOFSDS

   WHERE

      o.nsclass = 0 AND

      o.nsid = 4 AND

      o.pclass = 1 AND

      o.type = 'IT' AND

      has_access ( 'IT'par.indepidpar.depsubid ) = 1

 

 



RightSideLinks

 

 

 

 

 

 

 

Email Me