QUOTENAME
返回由分隔符包圍的 Unicode 字串,以使其成為有效的 SQL Server 分隔識別符號。
引數:
- 字串。一串 Unicode 資料,最多 128 個字元(
sysname
)。如果輸入字串超過 128 個字元,則函式返回null
。 - 引用字元。可選。用作分隔符的單個字元。可以是單引號(
'
或``),左支架或右支架({
,[
,(
,<
或>
,)
,]
,}
)或雙引號("
)。任何其他值都將返回 null。預設值為方括號。
SELECT QUOTENAME('what''s my name?') -- Returns [what's my name?]
SELECT QUOTENAME('what''s my name?', '[') -- Returns [what's my name?]
SELECT QUOTENAME('what''s my name?', ']') -- Returns [what's my name?]
SELECT QUOTENAME('what''s my name?', '''') -- Returns 'what''s my name?'
SELECT QUOTENAME('what''s my name?', '"') -- Returns "what's my name?"
SELECT QUOTENAME('what''s my name?', ')') -- Returns (what's my name?)
SELECT QUOTENAME('what''s my name?', '(') -- Returns (what's my name?)
SELECT QUOTENAME('what''s my name?', '<') -- Returns <what's my name?>
SELECT QUOTENAME('what''s my name?', '>') -- Returns <what's my name?>
SELECT QUOTENAME('what''s my name?', '{') -- Returns {what's my name?}
SELECT QUOTENAME('what''s my name?', '}') -- Returns {what's my name?}
SELECT QUOTENAME('what''s my name?', '`') -- Returns `what's my name?`