Home Microsoft SQL Server DigiMailing iRN Contact
    Keyword



sys.spt_tables_info_view

 

This is a view in the mssqlsystemresource database.




Syntax

create view sys.spt_tables_info_view
as
    select
    -- begin (for doing joins)
        OBJECT_ID               = o.object_id,
        SCHEMA_ID               = o.schema_id,
    -- end (for doing joins)
        TABLE_CATALOG           = db_name(),
        TABLE_SCHEMA            = schema_name(o.schema_id),
        TABLE_NAME              = o.name,
        TABLE_TYPE              = convert(nvarchar(30),
                                  case o.type
                                  when 'U' then
                                      case o.is_ms_shipped when 0
                                      then N'TABLE' else N'SYSTEM TABLE' end
                                  when 'S' then N'SYSTEM TABLE'
                                  when 'V' then
                                      case o.is_ms_shipped when 0
                                      then N'VIEW' else N'SYSTEM VIEW' end
                                  when 'SN' then N'SYNONYM'
                                  end),
        TABLE_GUID              = convert(uniqueidentifier, null),
        BOOKMARKS               = convert(bit, 1),
        BOOKMARK_TYPE           = convert(int, 1), --DBPROPVAL_BMK_NUMERIC
-- These are different for 32/64 bit clients, so handle them in the procedures.
--      BOOKMARK_DATATYPE       = convert(smallint, ?),
--      BOOKMARK_MAXIMUM_LENGTH = convert(int, ?),
        BOOKMARK_INFORMATION    = convert(int, 0),
        TABLE_VERSION           = convert(bigint, ObjectPropertyEx(o.object_id, 'objectversion')),
        CARDINALITY             = convert (int,
                                           case when o.type in ('U','S')
                                           then 0x7FFFFFFF & p.rows
                                           else NULL
                                           end),
        DESCRIPTION             = convert(nvarchar(1), null),
        TABLE_PROPID            = convert(int, null),
        TABLE_FLAGS             = convert
                                  (int,
                                    (
                                        case ObjectProperty(o.object_id, 'TableHasUpdateTrigger')
                                        when 1 then
                                        (
                                            case ObjectProperty(o.object_id, 'HasInsteadOfUpdateTrigger')
                                            when 1 then
                                            (
                                                case ObjectProperty(o.object_id, 'TableUpdateTriggerCount')
                                                when 0 then 0x00000001 -- TABLE_HAS_UPDATE_INSTEAD_OF_TRIGGER
                                                else        0x00000009 -- TABLE_HAS_UPDATE_INSTEAD_OF_TRIGGER & TABLE_HAS_AFTER_UPDATE_TRIGGER
                                                end
                                            )
                                            else 0x00000008 -- TABLE_HAS_AFTER_UPDATE_TRIGGER (or internal error)
                                            end
                                        )
                                        else 0 -- neither IOU triggers nor update triggers (or internal error)
                                        end
                                    ) |
                                    (
                                        case ObjectProperty(o.object_id, 'TableHasDeleteTrigger')
                                        when 1 then
                                        (
                                            case ObjectProperty(o.object_id, 'HasInsteadOfDeleteTrigger')
                                            when 1 then
                                            (
                                                case ObjectProperty(o.object_id, 'TableDeleteTriggerCount')
                                                when 0 then 0x00000002 -- TABLE_HAS_DELETE_INSTEAD_OF_TRIGGER
                                                else        0x00000012 -- TABLE_HAS_DELETE_INSTEAD_OF_TRIGGER & TABLE_HAS_AFTER_DELETE_TRIGGER
                                                end
                                            )
                                            else 0x00000010 -- TABLE_HAS_AFTER_DELETE_TRIGGER (or internal error)
                                            end
                                        )
                                        else 0 -- neither IOD triggers nor delete triggers (or internal error)
                                        end
                                    ) |
                                    (
                                        case ObjectProperty(o.object_id, 'TableHasInsertTrigger')
                                        when 1 then
                                        (
                                            case ObjectProperty(o.object_id, 'HasInsteadOfInsertTrigger')
                                            when 1 then
                                            (
                                                case ObjectProperty(o.object_id, 'TableInsertTriggerCount')
                                                when 0 then 0x00000004 -- TABLE_HAS_INSERT_INSTEAD_OF_TRIGGER
                                                else        0x00000024 -- TABLE_HAS_INSERT_INSTEAD_OF_TRIGGER & TABLE_HAS_AFTER_INSERT_TRIGGER
                                                end
                                            )
                                            else 0x00000020 -- TABLE_HAS_AFTER_INSERT_TRIGGER (or internal error)
                                            end
                                        )
                                        else 0 -- neither IOI triggers nor insert triggers (or internal error)
                                        end
                                    ) |
                                    (
                                        case ObjectProperty(o.object_id, 'TableHasCascadeUpdateForeignKey')
                                        when 1 then 0x00000040 -- TABLE_HAS_CASCADE_UPDATE
                                        else        0
                                        end
                                    ) |
                                    (
                                        case ObjectProperty(o.object_id, 'TableHasCascadeDeleteForeignKey')
                                        when 1 then 0x00000080 -- TABLE_HAS_CASCADE_DELETE
                                        else        0
                                        end
                                    )
                                  )
    from
        sys.all_objects o left join
        sys.indexes x on
        (
            x.index_id in (0,1) and
            o.object_id = x.object_id
        ) left join
        sys.index_counts p on
            (
                p.object_id = x.object_id and
                p.index_id = x.index_id
            )
    where
        o.type in ('U','V','S','SN')        -- user tables, views, system tables, synonyms


 
Last revision 2008RTM
See also

  sp_tables_info_90_rowset (Procedure)
sp_tables_info_90_rowset2 (Procedure)
sp_tables_info_90_rowset2_64 (Procedure)
sp_tables_info_90_rowset_64 (Procedure)
sp_tables_info_rowset (Procedure)
sp_tables_info_rowset2 (Procedure)
sp_tables_info_rowset2_64 (Procedure)
sp_tables_info_rowset_64 (Procedure)
       



News

  Query a named instance
Sybase+ASE+silent+install
SQL 2008 R2
Deprecated procedures in SQL2008
Reporting Services item-level role definitions
Create all your missing indexes
Converting datetime field
Start MSSQL Server Profiler at time
Replicating MSSQL Server views
Exploring Microsoft Sharepoint
The OLE DB provider "SQLNCLI10" for linked server indicates.
Mobile solar charger
Oracle to SQL Server replication
Cannot insert the value NULL into column
Undocumented Microsoft SQL Server 2008
VMware
Zoekmachine optimalisatie
SQL Servers hidden objects
FckEditor
Flash in Ajax
De hype die AJAX heet
Barcode scannen
MySQL; Gratis, makkelijk en snel!
PHP
sIFR; de combinatie tussen HTML en Flash