In SQL Server, the T-SQLÂ REPLICATE()
function repeats a string value a specified number of times and returns the result.
The function accepts two arguments; the input string, and the number of times it should be repeated.
In SQL Server, the T-SQLÂ REPLICATE()
function repeats a string value a specified number of times and returns the result.
The function accepts two arguments; the input string, and the number of times it should be repeated.
In SQL Server, the T-SQLÂ QUOTENAME()
function returns a Unicode string with the delimiters added to make the input string a valid SQL Server delimited identifier.
It was designed for quoting databases and their objects.
The function accepts two arguments; the input string (required), and a delimiter character (optional).
In SQL Server, you can use the T-SQLÂ PATINDEX()
function to find a pattern within a string. Specifically, the function only returns the first occurrence of the pattern within the string.
The function accepts two arguments; the pattern, and the string.
You can use wildcard characters within the pattern.
In SQL Server, you can use the T-SQLÂ NCHAR()
function to return the Unicode character based on the specified integer code.
You provide the integer code as an argument, and the function will return the Unicode character as defined by the Unicode standard.
In SQL Server, you can use the T-SQL RIGHT()
function to return a given number of characters from the right part of a string.
The function accepts two arguments; the string itself, and the number of characters you’d like to be returned from that string.
In SQL Server, you can use the T-SQL LEFT()
function to return a given number of characters from the left part of a string.
The function accepts two arguments; the string itself, and the number of characters you’d like to be returned from that string.
In SQL Server, you can use the T-SQL FORMAT()
function to return values such as numbers and dates as formatted strings.
You provide the value to be formatted, and you specify the format to use. The function accepts an optional argument that allows you to specify a culture to use when formatting the value.
Continue readingIn SQL Server, you can use the T-SQL CHARINDEX()
function to find the starting position of a character expression within another character expression.
You provide both character expressions as arguments. You can also provide an optional argument to specify a position in which to start the search.
There are many functions that are included in both MySQL and SQL Server. However, just because both DBMSs share functions of the same name, doesn’t mean that those functions work exactly the same way.
Take CHAR()
for example. Both MySQL and SQL Server include this function. Well technically, for SQL Server it’s actually a T-SQL function, but that’s beside the point. The point is that the MySQL CHAR()
function provides more functionality than the T-SQL/SQL Server CHAR()
function.
In particular, the MySQL version accepts multiple integers, whereas, the T-SQL version only accepts a single integer. The MySQL version also accepts a USING
clause that allows you to specify which character set to use (the T-SQL version doesn’t have this clause).
Below are some examples of these differences.
Transact-SQL contains a number of mathematical functions that you can use with SQL Server.
The following scalar functions can be used in SQL Server 2012 and above. Most of these functions accept one or more arguments, and will return a numeric value based on the argument/s supplied.