QUOTENAME (Transact-SQL)QUOTENAME (Transact-SQL)

適用於: 是SQL Server (從 2008 開始) 是Azure SQL Database 是Azure SQL 資料倉儲 是平行處理資料倉儲 APPLIES TO: yesSQL Server (starting with 2008) yesAzure SQL Database yesAzure SQL Data Warehouse yesParallel Data Warehouse

傳回 Unicode 字串,且附加了分隔符號,以便使輸入字串成為有效的 [SQL Server]SQL Server 分隔識別碼。Returns a Unicode string with the delimiters added to make the input string a valid [SQL Server]SQL Server delimited identifier.

主題連結圖示 Transact-SQL 語法慣例Topic link icon Transact-SQL Syntax Conventions

語法Syntax

QUOTENAME ( 'character_string' [ , 'quote_character' ] )   

引數Arguments

'character_string''character_string'
這是 Unicode 字元資料的字串。Is a string of Unicode character data. character_stringsysname,且限制為 128 個字元。character_string is sysname and is limited to 128 characters. 大於 128 個字元的輸入會傳回 NULL。Inputs greater than 128 characters return NULL.

'quote_character''quote_character'
這是用來當做分隔符號的單字元字串。Is a one-character string to use as the delimiter. 它可以是單引號 ( ' )、左或右方括弧 ( [] )、雙引號 ( " )、左或右括弧 ( () )、大於或小於符號 ( >< )、左或右大括弧 ( {} ) 或反勾號 ( ` )。Can be a single quotation mark ( ' ), a left or right bracket ( [] ), a double quotation mark ( " ), a left or right parenthesis ( () ), a greater than or less than sign ( >< ), a left or right brace ( {} ) or a backtick ( ` ). 如果提供了無法接受的字元,則會傳回 NULL。NULL returns if an unacceptable character is supplied. 如果未指定 quote_character,就會使用方括號。If quote_character is not specified, brackets are used.

傳回類型Return Types

nvarchar(258)nvarchar(258)

範例Examples

下列範例會使用字元字串 abc[]def,且利用 [] 字元來建立有效的 [SQL Server]SQL Server 分隔識別碼。The following example takes the character string abc[]def and uses the [ and ] characters to create a valid [SQL Server]SQL Server delimited identifier.

SELECT QUOTENAME('abc[]def');  

以下為結果集:Here is the result set.

[abc[]]def]  
  
(1 row(s) affected)  

請注意,abc[]def 字串中的兩個右方括號用來表示逸出字元。Notice that the right bracket in the string abc[]def is doubled to indicate an escape character.

範例:Azure SQL 資料倉儲Azure SQL Data Warehouse平行處理資料倉儲Parallel Data WarehouseExamples: Azure SQL 資料倉儲Azure SQL Data Warehouse and 平行處理資料倉儲Parallel Data Warehouse

下列範例會使用字元字串 abc def,且利用 [] 字元來建立有效的 [SQL Server]SQL Server 分隔識別碼。The following example takes the character string abc def and uses the [ and ] characters to create a valid [SQL Server]SQL Server delimited identifier.

SELECT QUOTENAME('abc def');   

以下為結果集:Here is the result set.

[abc def]  
  
(1 row(s) affected)  

另請參閱See Also

PARSENAME (Transact-SQL)PARSENAME (Transact-SQL)
CONCAT (Transact-SQL)CONCAT (Transact-SQL)
CONCAT_WS (Transact-SQL)CONCAT_WS (Transact-SQL)
FORMATMESSAGE (Transact-SQL)FORMATMESSAGE (Transact-SQL)
REPLACE (Transact-SQL)REPLACE (Transact-SQL)
REVERSE (Transact-SQL)REVERSE (Transact-SQL)
STRING_AGG (Transact-SQL)STRING_AGG (Transact-SQL)
STRING_ESCAPE (Transact-SQL)STRING_ESCAPE (Transact-SQL)
STUFF (Transact-SQL)STUFF (Transact-SQL)
TRANSLATE (Transact-SQL)TRANSLATE (Transact-SQL)
字串函數 (Transact-SQL)String Functions (Transact-SQL)