Beginning Microsoft SQL Server 2008 ... - S3 Tech Training

Beginning Microsoft SQL Server 2008 ... - S3 Tech Training Beginning Microsoft SQL Server 2008 ... - S3 Tech Training

cdn.s3techtraining.com
from cdn.s3techtraining.com More from this publisher
17.06.2013 Views

Appendix A: System Functions OBJECTPROPERTYEX OBJECTPROPERTYEX is an extended version of the OBJECTPROPERTY function. OBJECTPROPERTYEX(, ) Like OBJECTPROPERTY, the id parameter specifies the ID of the object required. The property parameter specifies the information required on the object. OBJECTPROPERTYEX supports all the same property values as OBJECTPROPERTY but adds the following property values as additional options: ❑ BaseType — Returns the base data type of an object. ❑ IsPrecise — Indicates that your object does not contain any imprecise computations. For example, an int or decimal is precise, but a float is not — computations that utilize imprecise data types must be assumed to return imprecise results. Note that you can specifically mark any .NET assemblies you produce as being precise or not. ❑ IsSystemVerified — Indicates whether the IsPrecise and IsDeterministic properties can be verified by SQL Server itself (as opposed to just having been set by the user). ❑ SchemaId — Just what it sounds like — returns the internal system ID for a given object. You can then use SCHEMA_NAME to put a more user-friendly name on the schema ID. ❑ SystemDataAccess — Indicates whether the object in question relies on any system table data. ❑ UserDataAccess — Indicates whether the object in question utilizes any of the user tables or system user data. @@PROCID Returns the stored procedure ID of the currently running procedure. Primarily a troubleshooting tool when a process is running and using up a large amount of resources. Is used mainly as a DBA function. SCHEMA_ID Given a schema name, returns the internal system ID for that schema. Utilizes the syntax: SCHEMA_ID( ) SCHEMA_NAME 626 Given an internal schema system ID, returns the user-friendly name for that schema. The syntax is: SCHEMA_NAME( )

SQL_VARIANT_PROPERTY SQL_VARIANT_PROPERTY is a powerful function and returns information about an sql_variant. This information could be from BaseType, Precision, Scale, TotalBytes, Collation, or MaxLength. The syntax is: SQL_VARIANT_PROPERTY (expression, property) Expression is an expression of type sql_variant. Property can be any one of the following values: Value Description Base Type of sql_variant Returned BaseType Data types include: char, int, money, nchar, ntext, numeric, nvarchar, real, smalldatetime, smallint, smallmoney, text, timestamp, tinyint, uniqueidentifier, varbinary, varchar Precision The precision of the numeric base data type: datetime = 23 smalldatetime = 16 float = 53 real = 24 decimal (p,s) and numeric (p,s) = p money = 19 smallmoney = 10 int = 10 smallint = 5 tinyint = 3 bit = 1 All other types = 0 Scale The number of digits to the right of the decimal point of the numeric base data type: decimal (p,s) and numeric (p,s) = s money and smallmoney = 4 datetime = 3 All other types = 0 TotalBytes The number of bytes required to hold both the metadata and data of the value. If the value is greater than 900, index creation will fail. Apendix A: System Functions sysname Collation The collation of the particular sql_variant value. sysname MaxLength The maximum data type length, in bytes. int int int int 627

Appendix A: System Functions<br />

OBJECTPROPERTYEX<br />

OBJECTPROPERTYEX is an extended version of the OBJECTPROPERTY function.<br />

OBJECTPROPERTYEX(, )<br />

Like OBJECTPROPERTY, the id parameter specifies the ID of the object required. The property parameter<br />

specifies the information required on the object. OBJECTPROPERTYEX supports all the same property values<br />

as OBJECTPROPERTY but adds the following property values as additional options:<br />

❑ BaseType — Returns the base data type of an object.<br />

❑ IsPrecise — Indicates that your object does not contain any imprecise computations. For example,<br />

an int or decimal is precise, but a float is not — computations that utilize imprecise data types<br />

must be assumed to return imprecise results. Note that you can specifically mark any .NET<br />

assemblies you produce as being precise or not.<br />

❑ IsSystemVerified — Indicates whether the IsPrecise and IsDeterministic properties<br />

can be verified by <strong>SQL</strong> <strong>Server</strong> itself (as opposed to just having been set by the user).<br />

❑ SchemaId — Just what it sounds like — returns the internal system ID for a given object. You<br />

can then use SCHEMA_NAME to put a more user-friendly name on the schema ID.<br />

❑ SystemDataAccess — Indicates whether the object in question relies on any system table data.<br />

❑ UserDataAccess — Indicates whether the object in question utilizes any of the user tables or<br />

system user data.<br />

@@PROCID<br />

Returns the stored procedure ID of the currently running procedure.<br />

Primarily a troubleshooting tool when a process is running and using up a large amount of resources. Is<br />

used mainly as a DBA function.<br />

SCHEMA_ID<br />

Given a schema name, returns the internal system ID for that schema. Utilizes the syntax:<br />

SCHEMA_ID( )<br />

SCHEMA_NAME<br />

626<br />

Given an internal schema system ID, returns the user-friendly name for that schema. The syntax is:<br />

SCHEMA_NAME( )

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!