SQL Server
SQL Server Common SQLServer charindex ( string_expression1 , string_expression2 [ , start_location ]  ) Searches "string_expression2" for the first occurrence of "string_expression1" and returns an integer. "Start_location" is the character position to start searching for "string_expression1" in "string_expression2". If "start_location" is not specified, is a negative number, or is zero, the search starts at the beginning of "string_expression2". concat ( string_expression1 , string_expression2 ) Returns a string that is the result of concatenating, or joining, "string_expression1" to "string_expression2". Example: concat ( [Sales (query)].[Sales staff].[First name], [Sales (query)].[Sales staff].[Last name] ) Result: Returns the first name and family name; e.g., Bob Smith. {current_user} { current_user } Returns the name of the current user. datalength ( string_expression ) Returns the length in bytes of "string_expression". dateadd ( { datepart } , integer_expression , date_expression ) Returns the date resulting from the addition of "integer_expression" units (indicated by "datepart" (day, month, year)) to "date_expression". datediff ( {datepart} , date_expression1 , date_expression2 ) Returns the number of "datepart" (day, month, year) units between "date_expression1" and "date_expression2". Example: datediff ( {yy} , 1984-01-01 , 1997-01-01 ) Result: 13 datename ( ' { ' datepart ' } ' , date_expression ) Returns "datepart" from "date_expression", which can be a datetime, smalldatetime, date, or time value as an ASCII string. Note that "datepart" must be a keyword representing a datepart or its abbreviation recognized by Microsoft® SQL Server and must be enclosed in curly brackets. Example: datename ( {mm} , 2000-01-01 ) Result: January datepart ( ' { ' datepart ' } ' , date_expression ) Returns part of "date_expression" (for example, the month) as an integer. "date_expression" can be a datetime, smalldatetime, date, or time value. Note that "datepart" must be a keyword representing a datepart or its abbreviation recognized by Microsoft® SQL Server and must be enclosed in curly brackets. Example: datepart ( {wk} , 2000-01-01 ) Result: 1 (first week of the year) day ( date_expression ) Returns the day portion of "date_expression". Same as extract (day from date_expression). difference ( string_expression1 , string_expression2 ) Returns an integer value representing the difference between the values returned by the data source-specific soundex function for "string_expression1" and "string_expression2". The value returned ranges from 0 to 4, with 4 indicating the best match. Note that 4 does not mean that the strings are equal. Example: difference ([Sales target (query)].[Sales Staff].[First name],[Sales (query)].[Retailers].[Contact first name]) Result: 0 Example: difference ([Sales target (query)].[Sales Staff].[First name],[Sales target (query)].[Sales Staff].[First name]) Result: 4 getdate () Returns a datetime value representing the current date and time of the computer that the database software runs on. isnull ( expression , expression ) Returns the first non-null argument (or null if both arguments are null). It is recommended to use the sql standard COALESCE function instead. Example: isnull ( [Sales (query)].[Sales Fact].[Sales quantity] , 0 ) Result: Returns the sales quantity if it's not null, otherwise returns 0. left ( string_expression , integer_expression ) Returns the leftmost "integer_expression" characters of "string_expression". Example: left ( [Sales (query)].[Sales staff].[Last name] , 3 ) Result: Returns the first three characters of each family name. ltrim ( string_expression ) Returns "string_expression" with leading spaces removed. month ( date_expression ) Returns the month portion of "date_expression". Same as extract (month from date_expression). patindex ( string_expression1 , string_expression2 ) Returns an integer that represents the starting position of the first occurrence of "string_expression1" in the "string_expression2". Returns 0 if "string_expression1" is not found. The % wildcard character must precede and follow "string_expression1", except when searching for first or last characters. Example: patindex ( '%po%', 'Report' ) Result: 3 replace ( string_expression1 , string_expression2 , string_expression3 ) Replaces all occurrences of "string_expression2" in "string_expression1" with "string_expression3". replicate ( string_expression , integer_expression ) Returns a string consisting of "string_expression" repeated "integer_expression" times. reverse ( string_expression ) Returns "string_expression" in reverse order. rtrim ( string_expression ) Returns "string_expression" with trailing spaces removed. Example: rtrim ( [Sales (query)].[Sales staff].[Last name] ) Result: Returns family names with any spaces at the end of the name removed. sign ( numeric_expression ) Returns an indicator of the sign "numeric_expression": +1 if "numeric_expression" is positive, 0 if zero or -1 if negative. space ( integer_expression ) Returns a string consisting of "integer_expression" spaces. str ( numeric_expression [ , integer_expression1 [ , integer_expression2 ] ] ) Returns a string representation of "numeric_expression" where "integer_expression1" is the length of the string returned and "integer_expression2" is the number of decimal digits. stuff ( string_expression1 , integer_expression1 , integer_expression2 , string_expression2 ) Returns a string where "integer_expression2" characters have been deleted from "string_expression1" beginning at "integer_expression1", and where "string_expression2" has been inserted into "string_expression1" at its start. The first character in a string is at position 1. year ( date_expression ) Returns the year portion of "date_expression". Same as extract (year from date_expression). ascii ( string_expression ) Returns a number representing the ascii code value of the leftmost character of "string_expression". Example: ascii ( 'A' ) Result: 65 char ( integer_expression ) Returns the character that has the ASCII code value specified by "integer_expression". "Integer_expression" should be between 0 and 255. Example: char ( 65 ) Result: A right ( string_expression , integer_expression ) Returns the rightmost "integer_expression" characters of "string_expression". round ( numeric_expression , integer_expression ) Returns "numeric_expression" rounded to the nearest value "integer_expression" places to the right of the decimal point. Rounding takes place before data formatting is applied. Example: round (125, -1) Result: 130 soundex ( string_expression ) Returns a four character string representing the sound of the words in "string_expression".
SQL Server Cast cast_float ( expression ) Returns the value of "expression" cast as a float. cast_real ( expression ) Returns the value of "expression" cast as a real. cast_smallint ( expression ) Returns the value of "expression" cast as a small integer. cast_integer ( expression ) Returns the value of "expression" cast as an integer. Example: integer ( 84.95 ) Result: 85 cast_timestamp ( expression ) Returns the value of "expression" cast as a datetime. cast_char ( expression ) Returns the value of "expression" cast as a character. A limit of 30 characters is returned. cast_varchar ( expression ) Returns the value of "expression" cast as a variable character.
SQL Server Math log ( numeric_expression ) Returns the natural logarithm of "numeric_expression". log10 ( numeric_expression ) Returns the base ten logarithm of "numeric_expression". pi () Returns the constant value of pi as a floating point value. rand ( integer_expression ) Generates a random number using "integer_expression" as the seed value.
SQL Server Trigonometry acos ( numeric_expression ) Returns the arccosine of "numeric_expression" in radians. The arccosine is the angle whose cosine is "numeric_expression". asin ( numeric_expression ) Returns the arcsine of "numeric_expression" in radians. The arcsine is the angle whose sine is "numeric_expression". atan ( numeric_expression ) Returns the arctangent of "numeric_expression" in radians. The arctangent is the angle whose tangent is "numeric_expression". atn2 ( numeric_expression1, numeric_expression2 ) Returns the arctangent of the x and y coordinates specified by "numeric_expression1" and "numeric_expression2", respectively, in radians. The arctangent is the angle whose tangent is "numeric_expression1". cos ( numeric_expression ) Returns the cosine of "numeric_expression" where "numeric_expression" is an angle expressed in radians. cot ( numeric_expression ) Returns the cotangent of "numeric_expression" where "numeric_expression" is an angle expressed in radians. degrees ( numeric_expression ) Returns "numeric_expression" radians converted to degrees. radians ( numeric_expression ) Returns the number of radians converted from "numeric_expression" degrees. sin ( numeric_expression ) Returns the sine of "numeric_expression" where "numeric_expression" is an angle expressed in radians. tan ( numeric_expression ) Returns the tangent of "numeric_expression" where "numeric_expression" is an angle expressed in radians.