How the STR() Function Works in SQL Server (T-SQL)

In SQL Server, the T-SQL STR() function returns character data converted from numeric data. The return value has a return type of varchar.

You provide the numeric data as an argument when calling the function. The function then converts it to character data. There are also two optional arguments that you can use to specify the length, and the number of places to the right of the decimal point.

Continue reading

How the SPACE() Function Works in SQL Server (T-SQL)

In SQL Server, you can use the T-SQL SPACE() function to generate a specific number of spaces.

This can be handy for adding spaces within a string, for example, when concatenating two or more strings.

The way it works is, you provide the number of spaces you need, and it will return a string of exactly that number of spaces.

Continue reading

How the QUOTENAME() Function Works in SQL Server (T-SQL)

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).

Continue reading