17.06.2013 Views

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

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

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

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>SQL</strong>_VARIANT_PROPERTY<br />

<strong>SQL</strong>_VARIANT_PROPERTY is a powerful function and returns information about an sql_variant. This<br />

information could be from BaseType, Precision, Scale, TotalBytes, Collation, or MaxLength. The<br />

syntax is:<br />

<strong>SQL</strong>_VARIANT_PROPERTY (expression, property)<br />

Expression is an expression of type sql_variant. Property can be any one of the following values:<br />

Value Description Base Type of<br />

sql_variant<br />

Returned<br />

BaseType Data types include: char, int, money, nchar, ntext,<br />

numeric, nvarchar, real, smalldatetime, smallint,<br />

smallmoney, text, timestamp, tinyint, uniqueidentifier,<br />

varbinary, varchar<br />

Precision The precision of the numeric base data type:<br />

datetime = 23<br />

smalldatetime = 16<br />

float = 53<br />

real = 24<br />

decimal (p,s) and numeric (p,s) = p<br />

money = 19<br />

smallmoney = 10<br />

int = 10<br />

smallint = 5<br />

tinyint = 3<br />

bit = 1<br />

All other types = 0<br />

Scale The number of digits to the right of the decimal<br />

point of the numeric base data type:<br />

decimal (p,s) and numeric (p,s) = s<br />

money and smallmoney = 4<br />

datetime = 3<br />

All other types = 0<br />

TotalBytes The number of bytes required to hold both the metadata and<br />

data of the value.<br />

If the value is greater than 900, index creation will fail.<br />

Apendix A: System Functions<br />

sysname<br />

Collation The collation of the particular sql_variant value. sysname<br />

MaxLength The maximum data type length, in bytes. int<br />

int<br />

int<br />

int<br />

627

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

Saved successfully!

Ooh no, something went wrong!