OBJECTPROPERTY (Transact-SQL)

 

THIS TOPIC APPLIES TO: yesSQL Server (starting with 2008)yesAzure SQL DatabaseyesAzure SQL Data Warehouse yesParallel Data Warehouse

Returns information about schema-scoped objects in the current database. For a list of schema-scoped objects, see sys.objects (Transact-SQL). This function cannot be used for objects that are not schema-scoped, such as data definition language (DDL) triggers and event notifications.

Topic link icon Transact-SQL Syntax Conventions

-- Syntax for SQL Server, Azure SQL Database, Azure SQL Data Warehouse, Parallel Data Warehouse  
  
OBJECTPROPERTY ( id , property )   

id
Is an expression that represents the ID of the object in the current database. id is int and is assumed to be a schema-scoped object in the current database context.

property
Is an expression that represents the information to be returned for the object specified by id. property can be one of the following values.

System_CAPS_ICON_note.jpg Note


Unless noted otherwise, NULL is returned when property is not a valid property name, id is not a valid object ID, id is an unsupported object type for the specified property, or the caller does not have permission to view the object's metadata.

Property nameObject typeDescription and values returned
CnstIsClustKeyConstraintPRIMARY KEY constraint with a clustered index.

1 = True

0 = False
CnstIsColumnConstraintCHECK, DEFAULT, or FOREIGN KEY constraint on a single column.

1 = True

0 = False
CnstIsDeleteCascadeConstraintFOREIGN KEY constraint with the ON DELETE CASCADE option.

1 = True

0 = False
CnstIsDisabledConstraintDisabled constraint.

1 = True

0 = False
CnstIsNonclustKeyConstraintPRIMARY KEY or UNIQUE constraint with a nonclustered index.

1 = True

0 = False
CnstIsNotReplConstraintConstraint is defined by using the NOT FOR REPLICATION keywords.

1 = True

0 = False
CnstIsNotTrustedConstraintConstraint was enabled without checking existing rows; therefore, the constraint may not hold for all rows.

1 = True

0 = False
CnstIsUpdateCascadeConstraintFOREIGN KEY constraint with the ON UPDATE CASCADE option.

1 = True

0 = False
ExecIsAfterTriggerTriggerAFTER trigger.

1 = True

0 = False
ExecIsAnsiNullsOnTransact-SQL function, Transact-SQL procedure, Transact-SQL trigger, viewSetting of ANSI_NULLS at creation time.

1 = True

0 = False
ExecIsDeleteTriggerTriggerDELETE trigger.

1 = True

0 = False
ExecIsFirstDeleteTriggerTriggerFirst trigger fired when a DELETE is executed against the table.

1 = True

0 = False
ExecIsFirstInsertTriggerTriggerFirst trigger fired when an INSERT is executed against the table.

1 = True

0 = False
ExecIsFirstUpdateTriggerTriggerFirst trigger fired when an UPDATE is executed against the table.

1 = True

0 = False
ExecIsInsertTriggerTriggerINSERT trigger.

1 = True

0 = False
ExecIsInsteadOfTriggerTriggerINSTEAD OF trigger.

1 = True

0 = False
ExecIsLastDeleteTriggerTriggerLast trigger fired when a DELETE is executed against the table.

1 = True

0 = False
ExecIsLastInsertTriggerTriggerLast trigger fired when an INSERT is executed against the table.

1 = True

0 = False
ExecIsLastUpdateTriggerTriggerLast trigger fired when an UPDATE is executed against the table.

1 = True

0 = False
ExecIsQuotedIdentOnTransact-SQL function, Transact-SQL procedure, Transact-SQL trigger, viewSetting of QUOTED_IDENTIFIER at creation time.

1 = True

0 = False
ExecIsStartupProcedureStartup procedure.

1 = True

0 = False
ExecIsTriggerDisabledTriggerDisabled trigger.

1 = True

0 = False
ExecIsTriggerNotForReplTriggerTrigger defined as NOT FOR REPLICATION.

1 = True

0 = False
ExecIsUpdateTriggerTriggerUPDATE trigger.

1 = True

0 = False
ExecIsWithNativeCompilationTransact-SQL ProcedureApplies to: SQL Server 2014 through SQL Server 2016.

Procedure is natively compiled.

1 = True

0 = False

Base data type: int
HasAfterTriggerTable, viewTable or view has an AFTER trigger.

1 = True

0 = False
HasDeleteTriggerTable, viewTable or view has a DELETE trigger.

1 = True

0 = False
HasInsertTriggerTable, viewTable or view has an INSERT trigger.

1 = True

0 = False
HasInsteadOfTriggerTable, viewTable or view has an INSTEAD OF trigger.

1 = True

0 = False
HasUpdateTriggerTable, viewTable or view has an UPDATE trigger.

1 = True

0 = False
IsAnsiNullsOnTransact-SQL function, Transact-SQL procedure, table, Transact-SQL trigger, viewSpecifies that the ANSI NULLS option setting for the table is ON. This means all comparisons against a null value evaluate to UNKNOWN. This setting applies to all expressions in the table definition, including computed columns and constraints, for as long as the table exists.

1 = True

0 = False
IsCheckCnstAny schema-scoped objectCHECK constraint.

1 = True

0 = False
IsConstraintAny schema-scoped objectIs a single column CHECK, DEFAULT, or FOREIGN KEY constraint on a column or table.

1 = True

0 = False
IsDefaultAny schema-scoped objectApplies to: SQL Server 2008 through SQL Server 2016.

Bound default.

1 = True

0 = False
IsDefaultCnstAny schema-scoped objectDEFAULT constraint.

1 = True

0 = False
IsDeterministicFunction, viewThe determinism property of the function or view.

1 = Deterministic

0 = Not Deterministic
IsEncryptedTransact-SQL function, Transact-SQL procedure, table, Transact-SQL trigger, viewIndicates that the original text of the module statement was converted to an obfuscated format. The output of the obfuscation is not directly visible in any of the catalog views in SQL Server 2005. Users without access to system tables or database files cannot retrieve the obfuscated text. However, the text is available to users that can either access system tables over the DAC port or directly access database files. Also, users that can attach a debugger to the server process can retrieve the original procedure from memory at run time.

1 = Encrypted

0 = Not encrypted

Base data type: int
IsExecutedAny schema-scoped objectObject can be executed (view, procedure, function, or trigger).

1 = True

0 = False
IsExtendedProcAny schema-scoped objectExtended procedure.

1 = True

0 = False
IsForeignKeyAny schema-scoped objectFOREIGN KEY constraint.

1 = True

0 = False
IsIndexedTable, viewTable or view that has an index.

1 = True

0 = False
IsIndexableTable, viewTable or view on which an index can be created.

1 = True

0 = False
IsInlineFunctionFunctionInline function.

1 = Inline function

0 = Not inline function
IsMSShippedAny schema-scoped objectObject created during installation of SQL Server.

1 = True

0 = False
IsPrimaryKeyAny schema-scoped objectPRIMARY KEY constraint.

1 = True

0 = False

NULL = Not a function, or object ID is not valid.
IsProcedureAny schema-scoped objectProcedure.

1 = True

0 = False
IsQuotedIdentOnTransact-SQL function, Transact-SQL procedure, table, Transact-SQL trigger, view, CHECK constraint, DEFAULT definitionSpecifies that the quoted identifier setting for the object is ON. This means double quotation marks delimit identifiers in all expressions involved in the object definition.

1 = ON

0 = OFF
IsQueueAny schema-scoped objectService Broker Queue

1 = True

0 = False
IsReplProcAny schema-scoped objectReplication procedure.

1 = True

0 = False
IsRuleAny schema-scoped objectBound rule.

1 = True

0 = False
IsScalarFunctionFunctionScalar-valued function.

1 = Scalar-valued function

0 = Not scalar-valued function
IsSchemaBoundFunction, viewA schema bound function or view created by using SCHEMABINDING.

1 = Schema-bound

0 = Not schema-bound.
IsSystemTableTableSystem table.

1 = True

0 = False
IsTableTableTable.

1 = True

0 = False
IsTableFunctionFunctionTable-valued function.

1 = Table-valued function

0 = Not table-valued function
IsTriggerAny schema-scoped objectTrigger.

1 = True

0 = False
IsUniqueCnstAny schema-scoped objectUNIQUE constraint.

1 = True

0 = False
IsUserTableTableUser-defined table.

1 = True

0 = False
IsViewViewView.

1 = True

0 = False
OwnerIdAny schema-scoped objectOwner of the object.

 Note: The schema owner is not necessarily the object owner. For example, child objects (those where parent_object_id is nonnull) will always return the same owner ID as the parent.

Nonnull = The database user ID of the object owner.
TableDeleteTriggerTableTable has a DELETE trigger.

>1 = ID of first trigger with the specified type.
TableDeleteTriggerCountTableTable has the specified number of DELETE triggers.

>0 = The number of DELETE triggers.
TableFullTextMergeStatusTableApplies to: SQL Server 2008 through SQL Server 2016.

Whether a table that has a full-text index that is currently in merging.

0 = Table does not have a full-text index, or the full-text index is not in merging.

1 = The full-text index is in merging.
TableFullTextBackgroundUpdateIndexOnTableApplies to: SQL Server 2008 through SQL Server 2016.

Table has full-text background update index (autochange tracking) enabled.

1 = TRUE

0 = FALSE
TableFulltextCatalogIdTableApplies to: SQL Server 2008 through SQL Server 2016.

ID of the full-text catalog in which the full-text index data for the table resides.

Nonzero = Full-text catalog ID, associated with the unique index that identifies the rows in a full-text indexed table.

0 = Table does not have a full-text index.
TableFulltextChangeTrackingOnTableApplies to: SQL Server 2008 through SQL Server 2016.

Table has full-text change-tracking enabled.

1 = TRUE

0 = FALSE
TableFulltextDocsProcessedTableApplies to: SQL Server 2008 through SQL Server 2016.

Number of rows processed since the start of full-text indexing. In a table that is being indexed for full-text search, all the columns of one row are considered as part of one document to be indexed.

0 = No active crawl or full-text indexing is completed.

> 0 = One of the following (A or B): A) The number of documents processed by insert or update operations since the start of Full, Incremental, or Manual change tracking population. B) The number of rows processed by insert or update operations since change tracking with background update index population was enabled, the full-text index schema changed, the full-text catalog rebuilt, or the instance of SQL Server restarted, and so on.

NULL = Table does not have a full-text index.

This property does not monitor or count deleted rows.
TableFulltextFailCountTableApplies to: SQL Server 2008 through SQL Server 2016.

Number of rows Full-Text Search did not index.

0 = The population has completed.

> 0 = One of the following (A or B): A) The number of documents that were not indexed since the start of Full, Incremental, and Manual Update change tracking population. B) For change tracking with background update index, the number of rows that were not indexed since the start of the population, or the restart of the population. This could be caused by a schema change, rebuild of the catalog, server restart, and so on.

NULL = Table does not have a full-text index.
TableFulltextItemCountTableApplies to: SQL Server 2008 through SQL Server 2016.

Number of rows that were successfully full-text indexed.
TableFulltextKeyColumnTableApplies to: SQL Server 2008 through SQL Server 2016.

ID of the column associated with the single-column unique index that is participating in the full-text index definition.

0 = Table does not have a full-text index.
TableFulltextPendingChangesTableApplies to: SQL Server 2008 through SQL Server 2016.

Number of pending change tracking entries to process.

0 = change tracking is not enabled.

NULL = Table does not have a full-text index.
TableFulltextPopulateStatusTableApplies to: SQL Server 2008 through SQL Server 2016.

0 = Idle.

1 = Full population is in progress.

2 = Incremental population is in progress.

3 = Propagation of tracked changes is in progress.

4 = Background update index is in progress, such as autochange tracking.

5 = Full-text indexing is throttled or paused.
TableHasActiveFulltextIndexTableApplies to: SQL Server 2008 through SQL Server 2016.

Table has an active full-text index.

1 = True

0 = False
TableHasCheckCnstTableTable has a CHECK constraint.

1 = True

0 = False
TableHasClustIndexTableTable has a clustered index.

1 = True

0 = False
TableHasDefaultCnstTableTable has a DEFAULT constraint.

1 = True

0 = False
TableHasDeleteTriggerTableTable has a DELETE trigger.

1 = True

0 = False
TableHasForeignKeyTableTable has a FOREIGN KEY constraint.

1 = True

0 = False
TableHasForeignRefTableTable is referenced by a FOREIGN KEY constraint.

1 = True

0 = False
TableHasIdentityTableTable has an identity column.

1 = True

0 = False
TableHasIndexTableTable has an index of any type.

1 = True

0 = False
TableHasInsertTriggerTableObject has an INSERT trigger.

1 = True

0 = False
TableHasNonclustIndexTableTable has a nonclustered index.

1 = True

0 = False
TableHasPrimaryKeyTableTable has a primary key.

1 = True

0 = False
TableHasRowGuidColTableTable has a ROWGUIDCOL for a uniqueidentifier column.

1 = True

0 = False
TableHasTextImageTableTable has a text, ntext, or image column.

1 = True

0 = False
TableHasTimestampTableTable has a timestamp column.

1 = True

0 = False
TableHasUniqueCnstTableTable has a UNIQUE constraint.

1 = True

0 = False
TableHasUpdateTriggerTableObject has an UPDATE trigger.

1 = True

0 = False
TableHasVarDecimalStorageFormatTableTable is enabled for vardecimal storage format.

1 = True

0 = False
TableInsertTriggerTableTable has an INSERT trigger.

>1 = ID of first trigger with the specified type.
TableInsertTriggerCountTableTable has the specified number of INSERT triggers.

>0 = The number of INSERT triggers.
TableIsFakeTableTable is not real. It is materialized internally on demand by the SQL Server Database Engine.

1 = True

0 = False
TableIsLockedOnBulkLoadTableTable is locked due to a bcp or BULK INSERT job.

1 = True

0 = False
TableIsMemoryOptimizedTableApplies to: SQL Server 2014 through SQL Server 2016.

Table is memory optimized

1 = True

0 = False

Base data type: int

For more information, see In-Memory OLTP (In-Memory Optimization).
TableIsPinnedTableTable is pinned to be held in the data cache.

0 = False

This feature is not supported in SQL Server 2005 and later.
TableTextInRowLimitTableMaximum bytes allowed for text in row.

0 if text in row option is not set.
TableUpdateTriggerTableTable has an UPDATE trigger.

> 1 = ID of first trigger with the specified type.
TableUpdateTriggerCountTableThe table has the specified number of UPDATE triggers.

> 0 = The number of UPDATE triggers.
TableHasColumnSetTableTable has a column set.

0 = False

1 = True

For more information, see Use Column Sets.
TableTemporalTypeTableApplies to: SQL Server 2016 through SQL Server 2016.

Specifies the type of table.

0 = non-temporal table

1 = history table for system-versioned table

2 = system-versioned temporal table

int

Returns NULL on error or if a caller does not have permission to view the object.

A user can only view the metadata of securables that the user owns or on which the user has been granted permission. This means that metadata-emitting, built-in functions such as OBJECTPROPERTY may return NULL if the user does not have any permission on the object. For more information, see Metadata Visibility Configuration.

The Database Engine assumes that object_id is in the current database context. A query that references an object_id in another database will return NULL or incorrect results. For example, in the following query the current database context is the master database. The Database Engine will try to return the property value for the specified object_id in that database instead of the database specified in the query. The query returns incorrect results because the view vEmployee is not in the master database.

USE master;  
GO  
SELECT OBJECTPROPERTY(OBJECT_ID(N'AdventureWorks2012.HumanResources.vEmployee'), 'IsView');  
GO  

OBJECTPROPERTY(view_id, 'IsIndexable') may consume significant computer resources because evaluation of IsIndexable property requires the parsing of view definition, normalization, and partial optimization. Although the IsIndexable property identifies tables or views that can be indexed, the actual creation of the index still might fail if certain index key requirements are not met. For more information, see CREATE INDEX (Transact-SQL).

OBJECTPROPERTY(table_id, 'TableHasActiveFulltextIndex') will return a value of 1 (true) when at least one column of a table is added for indexing. Full-text indexing becomes active for population as soon as the first column is added for indexing.

When a table is created, the QUOTED IDENTIFIER option is always stored as ON in the metadata of the table, even if the option is set to OFF when the table is created. Therefore, OBJECTPROPERTY(table_id, 'IsQuotedIdentOn') will always return a value of 1 (true).

A. Verifying that an object is a table

The following example tests whether UnitMeasure is a table in the AdventureWorks2012 database.

USE AdventureWorks2012;  
GO  
IF OBJECTPROPERTY (OBJECT_ID(N'Production.UnitMeasure'),'ISTABLE') = 1  
   PRINT 'UnitMeasure is a table.'  
ELSE IF OBJECTPROPERTY (OBJECT_ID(N'Production.UnitMeasure'),'ISTABLE') = 0  
   PRINT 'UnitMeasure is not a table.'  
ELSE IF OBJECTPROPERTY (OBJECT_ID(N'Production.UnitMeasure'),'ISTABLE') IS NULL  
   PRINT 'ERROR: UnitMeasure is not a valid object.';  
GO  
  

B. Verifying that a scalar-valued user-defined function is deterministic

The following example tests whether the user-defined scalar-valued function ufnGetProductDealerPrice, which returns a money value, is deterministic.

USE AdventureWorks2012;  
GO  
SELECT OBJECTPROPERTY(OBJECT_ID('dbo.ufnGetProductDealerPrice'), 'IsDeterministic');  
GO  

The result set shows that ufnGetProductDealerPrice is not a deterministic function.

-----

0

C. Finding the objects that belong to a specific schema

The following example uses the SchemaId property to return all the objects that belong to the schema Production.

USE AdventureWorks2012;  
GO  
SELECT name, object_id, type_desc  
FROM sys.objects   
WHERE OBJECTPROPERTY(object_id, N'SchemaId') = SCHEMA_ID(N'Production')  
ORDER BY type_desc, name;  
GO  

D: Verifying that an object is a table

The following example tests whether dbo.DimReseller is a table in the AdventureWorksPDW2012 database.

-- Uses AdventureWorks  
  
IF OBJECTPROPERTY (OBJECT_ID(N'dbo.DimReseller'),'ISTABLE') = 1  
   SELECT 'DimReseller is a table.'  
ELSE   
   SELECT 'DimReseller is not a table.';  
GO  

E: Finding the tables that belong to a specific schema

The following example returns all the tables in the dbo schema.

-- Uses AdventureWorks  
  
SELECT name, object_id, type_desc  
FROM sys.objects   
WHERE OBJECTPROPERTY(object_id, N'SchemaId') = SCHEMA_ID(N'dbo')  
ORDER BY type_desc, name;  
GO  

COLUMNPROPERTY (Transact-SQL)
Metadata Functions (Transact-SQL)
OBJECTPROPERTYEX (Transact-SQL)
ALTER AUTHORIZATION (Transact-SQL)
TYPEPROPERTY (Transact-SQL)
sys.objects (Transact-SQL)

Community Additions

ADD
Show: