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.

Appendix A: System Functions<br />

CAST and CONVERT<br />

These two functions provide similar functionality in that they both convert one data type into another<br />

type.<br />

Using CAST:<br />

CAST( AS )<br />

Using CONVERT:<br />

CONVERT ([()], [, ])<br />

Where style refers to the style of date format when converting to a character data type.<br />

COALESCE<br />

The COALESCE function is passed an undefined number of arguments and it tests for the first non-null<br />

expression among them. The syntax is as follows:<br />

COALESCE( [,...n])<br />

If all arguments are NULL then COALESCE returns NULL.<br />

COLLATIONPROPERTY<br />

The COLLATIONPROPERTY function returns the property of a given collation. The syntax is as follows:<br />

COLLATIONPROPERTY(, )<br />

The collation_name parameter is the name of the collation you wish to use, and property is the property<br />

of the collation you wish to determine. This can be one of three values:<br />

CURRENT_USER<br />

640<br />

Property Name Description<br />

CodePage The non-Unicode code page of the collation.<br />

LCID The Windows LCID of the collation. Returns NULL for <strong>SQL</strong> collations.<br />

ComparisonStyle The Windows comparison style of the collation. Returns NULL for binary or<br />

<strong>SQL</strong> collations.<br />

The CURRENT_USER function simply returns the current user as a sysname type. It is equivalent to<br />

USER_NAME(). The syntax is as follows:<br />

CURRENT_USER

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

Saved successfully!

Ooh no, something went wrong!