QUOTENAME (Transact-SQL)
Returns a Unicode string with the delimiters added to make the input string a valid Microsoft SQL Server delimited identifier.
The following example takes the character string abc[]def and uses the [ and ] characters to create a valid SQL Server delimited identifier.
SELECT QUOTENAME('abc[]def')
Here is the result set.
[abc[]]def] (1 row(s) affected)
Notice that the right bracket in the string abc[]def is doubled to indicate an escape character.
Documentation bug
return type should be nvarchar(128) instead of nvarchar(258)
--This works correctly
select
quotename(replicate('a', 128))--This returns null
select
quotename(replicate('a', 129))Not a documentation bug. The max result can be 258. An example would be:
select quotename(replicate(']', 128)) returns 258 brackets.
- 12/30/2008
- Sankar Reddy
- 5/26/2009
- jdufour
