Table 2-1 lists the different types of Transact-SQL functions and describes the type of information each returns.
Type of function |
Description |
---|---|
Generate summary values that appear as new columns or as additional rows in the query results. |
|
Change expressions from one datatype to another and specify new display formats for date and time information. |
|
Perform computations on datetime, smalldatetime, date, and time values and their components, date parts. |
|
Commonly needed for operations on mathematical data. |
|
Security-related information. |
|
Operate on binary data, character strings, and expressions. |
|
Retrieves special information from the database and database objects. |
|
Supply values commonly needed for operations on text, unitext, and image data. |
Table 2-2 lists the functions in alphabetical order.
Function |
Type |
Return value |
---|---|---|
Mathematical |
The absolute value of an expression. |
|
Mathematical |
The angle (in radians) with a specified cosine. |
|
String |
The ASCII code for the first character in an expression. |
|
Mathematical |
The angle (in radians) with a specified sine. |
|
Mathematical |
The angle (in radians) with a specified tangent. |
|
Mathematical |
The angle (in radians) with specified sine and cosine. |
|
Security |
A description of an audit event |
|
Aggregate |
The numeric average of all (distinct) values. |
|
Datatype conversion |
Returns the platform-independent hexadecimal equivalent of the specified integer. |
|
Allows SQL expressions to be written for conditional values. case expressions can be used anywhere a value expression can be used. |
||
Datatype conversion |
A specified value, converted to another datatype |
|
Mathematical |
The smallest integer greater than or equal to the specified value. |
|
String |
The character equivalent of an integer. |
|
String |
Returns an integer representing the starting position of an expression. |
|
String |
The number of characters in an expression. |
|
System |
The defined length of a column. |
|
System |
The name of the column with specified table and column IDs. |
|
System |
Returns the following values, based on the collation rules that you chose:
|
|
Datatype conversion |
The specified value, converted to another datatype or a different datetime display format. |
|
Mathematical |
The cosine of the specified angle (in radians). |
|
Mathematical |
The cotangent of the specified angle (in radians). |
|
Aggregate |
The number of (distinct) non-null values as an integer. |
|
Aggregrate |
The number of (distinct) non-null values as a bigint. |
|
Date |
Returns the current date. |
|
Date |
Returns the current time. |
|
System |
The number of free pages in the specified disk piece. |
|
System |
The number of pages used by the specified table or index. |
|
System |
The actual length, in bytes, of the specified column or string. |
|
Date |
The date produced by adding a given number of years, quarters, hours, or other date parts to the specified date. |
|
Date |
The difference between two date expressions. |
|
Date |
The name of the specified part of a date expression. |
|
Date |
The integer value of the specified part of a date expression. |
|
Date |
Returns an integer that represents the day in the datepart of a specified date. |
|
System |
The ID number of the specified database. |
|
System |
The name of the database with a specified ID number. |
|
Mathematical |
The size, in degrees, of an angle with a specified number of radians. |
|
System |
Returns derived statistics for the specified object and index. |
|
String |
The difference between two soundex values. |
|
Mathematical |
The value that results from raising the constant e to the specified power. |
|
Mathematical |
The largest integer that is less than or equal to the specified value. |
|
Security |
Returns the value of the attribute in a specified context. |
|
Date |
The current system date and time. |
|
Datatype conversion |
The bigint value equivalent of a hexadecimal string |
|
Datatype conversion |
The platform-independent integer equivalent of the specified hexadecimal string. |
|
System |
Returns the client computer’s operating system process ID for the current Adaptive Server client. |
|
System |
The current host computer name of the client process. |
|
The identity_burn_max value. |
||
System |
The name of the indexed column in the specified table or view. |
|
System |
Returns the column order |
|
Datatype conversion |
The platform-independent, hexadecimal equivalent of the specified integer. |
|
Datatype conversion |
Determines whether an input expression is a valid datetime value |
|
Datatype conversion |
Determines if an expression is a valid numeric datatype |
|
System |
Indicates whether a database is in quiesce database mode. is_quiesced returns 1 if the database is quiesced and 0 if it is not. |
|
Security |
1 if the security service is active; 0 if it is not. |
|
System |
Substitutes the value specified in expression2 when expression1 evaluates to NULL. |
|
System |
Manages the last-chance threshold. |
|
String |
Returns a specified number of characters on the left end of a character string. |
|
String |
Returns the number of characters, not the number of bytes, of a specified string expression, excluding trailing blanks. |
|
System |
1” if the feature’s license is enabled; 0 if it is not. |
|
Security |
Lists all the attributes of all the contexts in the current session. |
|
Mathematical |
Returns the locking scheme of the specified object as a string. |
|
Mathematical |
The natural logarithm of the specified number. |
|
Mathematical |
The base 10 logarithm of the specified number. |
|
String |
The lowercase equivalent of the specified expression. |
|
String |
The specified expression, trimmed of leading blanks |
|
Aggregate |
The highest value in a column. |
|
Aggregate |
The lowest value in a column. |
|
Date |
An integer that represents the month in the datepart of a specified date |
|
Security |
The mutual exclusivity between two roles. |
|
System |
Generates human-readable, globally unique IDs (GUIDs) in two different formats, based on arguments you provide. |
|
System |
Retrieves the next identity value that is available for the next insert. |
|
Allows SQL expressions to be written for conditional values. nullif expressions can be used anywhere a value expression can be used; alternative for a case expression. |
||
System |
The object ID of the specified object. |
|
System |
The name of the object with the specified object ID. |
|
Mathematical |
Returns the page size, in bytes, for the specified object. |
|
System |
Returns the partition ID of the specified data or index partition name. |
|
System |
The explicit name of a new partition, partition_name returns the partition name of the specified data or index partition id. |
|
System |
Displays the object ID for a specified partition ID and database ID. |
|
String, Text, Unitext, and Image |
The starting position of the first occurrence of a specified pattern. |
|
Mathematical |
The constant value 3.1415926535897936. |
|
Mathematical |
The value that results from raising the specified number to a given power. |
|
Security |
1 if the user has the correct role to execute the procedure; 0 if the user does not have this role. |
|
Mathematical |
The size, in radians, of an angle with a specified number of degrees. |
|
Mathematical |
A random value between 0 and 1, generated using the specified seed value. |
|
String |
A string consisting of the specified expression repeated a given number of times. |
|
System |
The number of pages allocated to the specified table or index. |
|
String |
The specified string, with characters listed in reverse order. |
|
String |
The part of the character expression, starting the specified number of characters from the right. |
|
Security |
Removes a specific application context, or all application contexts. |
|
Security |
1 if role2 contains role1. |
|
Security |
The system role ID of the role with the name you specify. |
|
Security |
The name of a role with the system role ID you specify. |
|
Mathematical |
The value of the specified number, rounded to a given number of decimal places. |
|
System |
An estimate of the number of rows in the specified table. |
|
String |
The specified expression, trimmed of trailing blanks. |
|
Security |
Sets an application context name, attribute name, and attribute value for a user session, defined by the attributes of a specified application. |
|
Security |
The login’s currently active roles. |
|
Security |
A list of the user’s currently active security services. |
|
Mathematical |
The sign (+1 for positive, 0, or -1 for negative) of the specified value. |
|
Mathematical |
The sine of the specified angle (in radians). |
|
System |
Values that can be used to order results based on collation behavior, which allows you to work with character collation behaviors beyond the default set of Latin-character-based dictionary sort orders and case or accent sensitivity. |
|
String |
A 4-character code representing the way an expression sounds. |
|
String |
A string consisting of the specified number of single-byte spaces. |
|
Mathematical |
Returns the square of a specified value expressed as a float. |
|
Mathematical |
The square root of the specified number. |
|
String |
The character equivalent of the specified number. |
|
String |
Replaces any instances of the second string expression that occur within the first string expression with a third expression. |
|
String |
The string formed by deleting a specified number of characters from one string and replacing them with another string. |
|
String |
The string formed by extracting a specified number of characters from another string. |
|
Aggregate |
The total of the values. |
|
System |
The server user’s ID number from the syslogins system table. |
|
System |
The name of the current server user, or the user where the server user ID is specified. |
|
System |
Terminates the connection. |
|
System |
Sends a message to a User Datagram Protocol (UDP) port. |
|
Mathematical |
The tangent of the specified angle (in radians). |
|
System |
The database ID of the temporary database assigned to the specified spid |
|
Text, Unitext, and Image |
The pointer to the first page of the specified text column. |
|
Text and Image |
1 if the pointer to the specified text column is valid; 0 if it is not. |
|
String |
A unichar expression having the value of the integer expression. |
|
System |
Returns a true/false indication of whether dump transaction is allowed. |
|
System |
Compares timestamp values to prevent update on a row that has been modified since it was selected for browsing. |
|
String |
1 if the Unicode value at position start is the high half of a surrogate pair (which should appear first in the pair); otherwise 0. |
|
String |
1 if the Unicode value at position start is the low half of a surrogate pair (which should appear second in the pair); otherwise 0. |
|
String |
The uppercase equivalent of the specified string. |
|
String |
The Unicode scalar value for the first Unicode character in an expression. |
|
System |
The number of pages used by the specified table and its clustered index. |
|
System |
The name of the current server user. |
|
System |
The ID number of the specified user or the current user. |
|
System |
The name within the database of the specified user or the current user. |
|
System |
0 if the specified string is not a valid identifier; a number other than 0 if the string is valid. |
|
System |
1 if the specified ID is a valid user or alias in at least one database on this Adaptive Server. |
|
Date |
An integer that represents the year in the datepart of a specified date. |
The following sections describe the types of functions in detail. The remainder of the chapter contains descriptions of the individual functions in alphabetical order.