Function is a database object in SQL Server. Basically, it is a set of SQL statements that accept only input parameters, perform actions and return the result. Function can return an only single value or a table. We can’t use a function to Insert, Update, Delete records in the database table(s).
In T-SQL, a function is considered an object. Here are some of the rules when creating functions in SQL Server.
MySQL Advanced Functions
Function Description BIN Returns a binary representation of a number BINARY Converts a value to a binary string CASE Goes through conditions and return a value when the first condition is met CAST Converts a value (of any type) into a specified datatype COALESCE Returns the first non-null value in a list CONNECTION_ID Returns the unique connection ID for the current connection CONV Converts a number from one numeric base system to another CONVERT Converts a value into the specified datatype or character set CURRENT_USER Returns the user name and host name for the MySQL account that the server used to authenticate the current client DATABASE Returns the name of the current database IF Returns a value if a condition is TRUE, or another value if a condition is FALSE IFNULL Return a specified value if the expression is NULL, otherwise return the expression ISNULL Returns 1 or 0 depending on whether an expression is NULL LAST_INSERT_ID Returns the AUTO_INCREMENT id of the last row that has been inserted or updated in a table NULLIF Compares two expressions and returns NULL if they are equal. Otherwise, the first expression is returned SESSION_USER Returns the current MySQL user name and host name SYSTEM_USER Returns the current MySQL user name and host name USER Returns the current MySQL user name and host name VERSION Returns the current version of the MySQL database
SQL Server String Functions
Function Description ASCII Returns the ASCII value for the specific character CHAR Returns the character based on the ASCII code CHARINDEX Returns the position of a substring in a string CONCAT Adds two or more strings together Concat with + Adds two or more strings together CONCAT_WS Adds two or more strings together with a separator DATALENGTH Returns the number of bytes used to represent an expression DIFFERENCE Compares two SOUNDEX values, and returns an integer value FORMAT Formats a value with the specified format LEFT Extracts a number of characters from a string (starting from left) LEN Returns the length of a string LOWER Converts a string to lower-case LTRIM Removes leading spaces from a string NCHAR Returns the Unicode character based on the number code PATINDEX Returns the position of a pattern in a string QUOTENAME Returns a Unicode string with delimiters added to make the string a valid SQL Server delimited identifier REPLACE Replaces all occurrences of a substring within a string, with a new substring REPLICATE Repeats a string a specified number of times REVERSE Reverses a string and returns the result RIGHT Extracts a number of characters from a string (starting from right) RTRIM Removes trailing spaces from a string SOUNDEX Returns a four-character code to evaluate the similarity of two strings SPACE Returns a string of the specified number of space characters STR Returns a number as string STUFF Deletes a part of a string and then inserts another part into the string, starting at a specified position SUBSTRING Extracts some characters from a string TRANSLATE Returns the string from the first argument after the characters specified in the second argument are translated into the characters specified in the third argument. TRIM Removes leading and trailing spaces (or other specified characters) from a string UNICODE Returns the Unicode value for the first character of the input expression UPPER Converts a string to upper-case
SQL Server Math/Numeric Functions
Function Description ABS Returns the absolute value of a number ACOS Returns the arc cosine of a number ASIN Returns the arc sine of a number ATAN Returns the arc tangent of a number ATN2 Returns the arc tangent of two numbers AVG Returns the average value of an expression CEILING Returns the smallest integer value that is &gt;= a number COUNT Returns the number of records returned by a select query COS Returns the cosine of a number COT Returns the cotangent of a number DEGREES Converts a value in radians to degrees EXP Returns e raised to the power of a specified number FLOOR Returns the largest integer value that is