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 RAND The RAND function returns a random value between 0 and 1. The syntax is as follows: RAND([]) The optional seed value is an integer expression, which specifies a start value to be used in random number generation. You can allow SQL Server to generate its own random seed value each time you call it, or you can specify your own. ROUND Be careful when specifying a literal seed value. Given a specific seed value, SQL Server will always return the same result (meaning your RAND is suddenly not random at all). If you truly need a random number generated, then either allow SQL Server to select a random seed for you, or use a constantly changing seed such as the number of nanoseconds since a particular point in time. The ROUND function takes a number specified in expression and rounds it to the specified length: ROUND(, [, ]) The length parameter specifies the precision to which expression should be rounded. The length parameter should be of the tinyint, smallint, or int data type. The optional function parameter can be used to specify whether the number should be rounded or truncated. If a function value is omitted or is equal to 0 (the default), the value in expression will be rounded. If any value other than 0 is provided, the value in expression will be truncated. SIGN SIN The SIGN function returns the sign of the expression. The possible return values are +1 for a positive number, 0 for zero, and -1 for a negative number. The syntax is as follows: SIGN() The SIN function returns the sine of an angle. The syntax is as follows: SIN() The angle should be in radians and must be of the float data type. The return value will also be of the float data type. SQRT 614 The SQRT function returns the square root of the value given in expression. The syntax is as follows: SQRT()

The expression must be of the float data type. SQUARE TAN The SQUARE function returns the square of the value given in expression. The syntax is as follows: SQUARE() The expression must be of the float data type. The TAN function returns the tangent of the value specified in expression. The syntax is as follows: TAN() The expression parameter specifies the number of radians and must be of the float or real data type. Basic Metadata Functions The metadata functions provide information about the database and database objects. They are: ❑ COL_LENGTH ❑ COL_NAME ❑ COLUMNPROPERTY ❑ DATABASEPROPERTY ❑ DATABASEPROPERTYEX ❑ DB_ID ❑ DB_NAME ❑ FILE_ID ❑ FILE_NAME ❑ FILEGROUP_ID ❑ FILEGROUP_NAME ❑ FILEGROUPPROPERTY ❑ FILEPROPERTY ❑ FULLTEXTCATALOGPROPERTY ❑ FULLTEXTSERVICEPROPERTY ❑ INDEX_COL Apendix A: System Functions 615

Appendix A: System Functions<br />

RAND<br />

The RAND function returns a random value between 0 and 1. The syntax is as follows:<br />

RAND([])<br />

The optional seed value is an integer expression, which specifies a start value to be used in random<br />

number generation. You can allow <strong>SQL</strong> <strong>Server</strong> to generate its own random seed value each time you call<br />

it, or you can specify your own.<br />

ROUND<br />

Be careful when specifying a literal seed value. Given a specific seed value, <strong>SQL</strong> <strong>Server</strong> will always<br />

return the same result (meaning your RAND is suddenly not random at all). If you truly need a<br />

random number generated, then either allow <strong>SQL</strong> <strong>Server</strong> to select a random seed for you, or use<br />

a constantly changing seed such as the number of nanoseconds since a particular point in time.<br />

The ROUND function takes a number specified in expression and rounds it to the specified length:<br />

ROUND(, [, ])<br />

The length parameter specifies the precision to which expression should be rounded. The length<br />

parameter should be of the tinyint, smallint, or int data type. The optional function parameter<br />

can be used to specify whether the number should be rounded or truncated. If a function value is<br />

omitted or is equal to 0 (the default), the value in expression will be rounded. If any value other than 0<br />

is provided, the value in expression will be truncated.<br />

SIGN<br />

SIN<br />

The SIGN function returns the sign of the expression. The possible return values are +1 for a positive<br />

number, 0 for zero, and -1 for a negative number. The syntax is as follows:<br />

SIGN()<br />

The SIN function returns the sine of an angle. The syntax is as follows:<br />

SIN()<br />

The angle should be in radians and must be of the float data type. The return value will also be of the<br />

float data type.<br />

SQRT<br />

614<br />

The SQRT function returns the square root of the value given in expression. The syntax is as follows:<br />

SQRT()

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

Saved successfully!

Ooh no, something went wrong!