Syntax :
QUOTENAME ( 'character_string' [ , 'quote_character' ] )
If the character_string or column value is greater than the 128 characters then quotename function will returns NULL.
Example`s :
SELECT Quotename('satya')
Result : [satya]
Note : If quote_character is not specified, by default it take brackets.
SELECT Quotename('satya', '(')
Result : (satya) SELECT Quotename('satya', '{')
Result : {satya} SELECT Quotename('satya', '[')
Result : [satya] SELECT Quotename('satya', '''')
Result : 'satya' SELECT Quotename('satya', '"')
Result : "satya" SELECT Quotename('satya', '<')
Result : <satya>
Applying QUOTENAME Function to Column :
CREATE TABLE table_quotename ( info VARCHAR(250) ) INSERT INTO table_quotename SELECT Replicate('satya mssql', 2) UNION ALL SELECT Replicate('satya mssql', 4) UNION ALL SELECT Replicate('satya mssql', 13) SELECT Quotename(info), Quotename(info, '['), Quotename(info, '{'), Quotename(info, ''''), Quotename(info, '(') FROM table_quotename
In the above query result last column values are showing as NULL, because values in the third row is greater than 128 characters that`s why result is NULL.
No comments:
Post a Comment