SET QUOTED_IDENTIFIER(Transact-SQL)SET QUOTED_IDENTIFIER (Transact-SQL)
적용 대상:Applies to: SQL ServerSQL Server(지원되는 모든 버전)
SQL ServerSQL Server (all supported versions)
Azure SQL DatabaseAzure SQL Database
Azure SQL DatabaseAzure SQL Database
Azure SQL Managed InstanceAzure SQL Managed Instance
Azure SQL Managed InstanceAzure SQL Managed Instance
Azure Synapse AnalyticsAzure Synapse Analytics
Azure Synapse AnalyticsAzure Synapse Analytics
병렬 데이터 웨어하우스Parallel Data Warehouse
병렬 데이터 웨어하우스Parallel Data Warehouse
SQL ServerSQL Server(지원되는 모든 버전)
SQL ServerSQL Server (all supported versions)
Azure SQL DatabaseAzure SQL Database
Azure SQL DatabaseAzure SQL Database
Azure SQL Managed InstanceAzure SQL Managed Instance
Azure SQL Managed InstanceAzure SQL Managed Instance
Azure Synapse AnalyticsAzure Synapse Analytics
Azure Synapse AnalyticsAzure Synapse Analytics
병렬 데이터 웨어하우스Parallel Data Warehouse
병렬 데이터 웨어하우스Parallel Data Warehouse
SQL ServerSQL Server가 인용 부호 구분 식별자 및 리터럴 문자열에 관해 ISO 규칙을 따르도록 합니다.Causes SQL ServerSQL Server to follow the ISO rules regarding quotation mark delimiting identifiers and literal strings. 큰따옴표로 구분된 식별자는 Transact-SQLTransact-SQL 예약 키워드이거나 Transact-SQLTransact-SQL 식별자 규칙 구문에서 일반적으로 허용하지 않는 문자를 포함할 수 있습니다.Identifiers delimited by double quotation marks can be either Transact-SQLTransact-SQL reserved keywords or can contain characters not generally allowed by the Transact-SQLTransact-SQL syntax rules for identifiers.
Transact-SQL 구문 표기 규칙
Transact-SQL Syntax Conventions
구문Syntax
-- Syntax for SQL Server, Azure SQL Database and serverless SQL pool in Azure Synapse Analytics
SET QUOTED_IDENTIFIER { ON | OFF }
-- Syntax for Azure Synapse Analytics and Parallel Data Warehouse
SET QUOTED_IDENTIFIER ON
참고
SQL Server 2014 이전 버전의 Transact-SQL 구문을 보려면 이전 버전 설명서를 참조하세요.To view Transact-SQL syntax for SQL Server 2014 and earlier, see Previous versions documentation.
설명Remarks
SET QUOTED_IDENTIFIER
가 ON(기본값)이면, 식별자는 큰따옴표(“ ”)로 구분할 수 있고 리터럴은 작은따옴표(‘ ’)로 구분해야 합니다.When SET QUOTED_IDENTIFIER
is ON (default), identifiers can be delimited by double quotation marks (" "), and literals must be delimited by single quotation marks (' '). 큰따옴표로 구분되는 모든 문자열은 개체 식별자로 해석됩니다.All strings delimited by double quotation marks are interpreted as object identifiers. 따라서 따옴표 붙은 식별자는 Transact-SQLTransact-SQL 식별자 규칙을 따르지 않아도 됩니다.Therefore, quoted identifiers do not have to follow the Transact-SQLTransact-SQL rules for identifiers. 따옴표 붙은 식별자는 예약 키워드일 수 있으며 Transact-SQLTransact-SQL 식별자에서 일반적으로 허용되지 않는 문자를 포함할 수 있습니다.They can be reserved keywords and can include characters not generally allowed in Transact-SQLTransact-SQL identifiers. 큰따옴표로는 리터럴 문자열 식을 구분할 수 없습니다. 리터럴 문자열을 묶으려면 작은따옴표를 사용해야 합니다.Double quotation marks cannot be used to delimit literal string expressions; single quotation marks must be used to enclose literal strings. 리터럴 문자열에 작은따옴표(‘)가 포함되어 있으면, 두 개의 작은따옴표(‘’)로 나타낼 수 있습니다.If a single quotation mark (') is part of the literal string, it can be represented by two single quotation marks (''). 데이터베이스의 개체 이름에 예약된 키워드를 사용하는 경우 SET QUOTED_IDENTIFIER
를 ON으로 설정해야 합니다.SET QUOTED_IDENTIFIER
must be ON when reserved keywords are used for object names in the database.
SET QUOTED_IDENTIFIER
가 OFF이면, 식별자를 따옴표로 묶을 수 없으며 모든 Transact-SQLTransact-SQL 식별자 규칙을 따라야 합니다.When SET QUOTED_IDENTIFIER
is OFF, identifiers cannot be quoted and must follow all Transact-SQLTransact-SQL rules for identifiers. 자세한 내용은 Database Identifiers을 참조하세요.For more information, see Database Identifiers. 리터럴은 작은따옴표 또는 큰따옴표로 구분할 수 있습니다.Literals can be delimited by either single or double quotation marks. 리터럴 문자열을 큰따옴표로 구분할 때 아포스트로피와 같은 작은따옴표가 들어갈 수 있습니다.If a literal string is delimited by double quotation marks, the string can contain embedded single quotation marks, such as apostrophes.
참고
QUOTED_IDENTIFIER는 대괄호([ ])로 묶인 구분 식별자에 영향을 주지 않습니다.QUOTED_IDENTIFIER does not affect delimited identifiers enclosed in brackets ([ ]).
계산 열이나 인덱싱된 뷰에서 인덱스를 만들거나 변경하는 경우 SET QUOTED_IDENTIFIER
를 ON으로 설정해야 합니다.SET QUOTED_IDENTIFIER
must be ON when you are creating or changing indexes on computed columns or indexed views. SET QUOTED_IDENTIFIER
가 OFF이면, 계산 열에 인덱스가 있는 테이블이나 인덱싱된 뷰가 있는 테이블에서 CREATE, UPDATE, INSERT, DELETE 문이 실패합니다.If SET QUOTED_IDENTIFIER
is OFF, then CREATE, UPDATE, INSERT, and DELETE statements will fail on tables with indexes on computed columns, or tables with indexed views. 계산 열의 인덱스 및 인덱싱된 뷰에 필요한 SET 옵션 설정에 대한 자세한 내용은 SET 문 사용 시 고려 사항을 참조하세요.For more information about required SET option settings with indexed views and indexes on computed columns, see Considerations when you use the SET statements.
필터링된 인덱스를 만드는 경우 SET QUOTED_IDENTIFIER
를 ON으로 설정해야 합니다.SET QUOTED_IDENTIFIER
must be ON when you are creating a filtered index.
XML 데이터 형식 메서드를 호출하는 경우 SET QUOTED_IDENTIFIER
를 ON으로 설정해야 합니다.SET QUOTED_IDENTIFIER
must be ON when you invoke XML data type methods.
SQL ServerSQL Server Native Client ODBC 드라이버와 SQL ServerSQL Server용 SQL ServerSQL Server Native Client OLE DB 공급자는 연결할 때 QUOTED_IDENTIFIER를 자동으로 ON으로 설정합니다.The SQL ServerSQL Server Native Client ODBC driver and SQL ServerSQL Server Native Client OLE DB Provider for SQL ServerSQL Server automatically set QUOTED_IDENTIFIER to ON when connecting. ODBC 데이터 원본과 ODBC 연결 특성 또는 OLE DB 연결 특성에서 이 옵션을 구성할 수 있습니다.This can be configured in ODBC data sources, in ODBC connection attributes, or OLE DB connection properties. DB-Library 애플리케이션에서 연결하려면 SET QUOTED_IDENTIFIER의 기본값이 OFF여야 합니다.The default for SET QUOTED_IDENTIFIER is OFF for connections from DB-Library applications.
테이블이 생성될 때 QUOTED IDENTIFIER 옵션이 OFF로 설정되어 있는 경우에도 해당 테이블의 메타데이터에는 항상 ON으로 저장됩니다.When a table is created, the QUOTED IDENTIFIER option is always stored as ON in the table's metadata even if the option is set to OFF when the table is created.
저장 프로시저를 만들 때 SET QUOTED_IDENTIFIER와 SET ANSI_NULLS 설정이 캡처되어 이후에 이 저장 프로시저를 호출할 때 사용됩니다.When a stored procedure is created, the SET QUOTED_IDENTIFIER and SET ANSI_NULLS settings are captured and used for subsequent invocations of that stored procedure.
저장 프로시저 내에서 실행할 때는 SET QUOTED_IDENTIFIER 설정이 변경되지 않습니다.When executed inside a stored procedure, the setting of SET QUOTED_IDENTIFIER is not changed.
SET ANSI_DEFAULTS
가 ON이면, QUOTED_IDENTIFIER도 ON이 됩니다.When SET ANSI_DEFAULTS
is ON, QUOTED_IDENTIFIER is also ON.
또한 SET QUOTED_IDENTIFIER
는 ALTER DATABASE의 QUOTED_IDENTIFIER 설정에 해당합니다.SET QUOTED_IDENTIFIER
also corresponds to the QUOTED_IDENTIFIER setting of ALTER DATABASE.
SET QUOTED_IDENTIFIER
는 Transact-SQLTransact-SQL 구문 분석 시 적용되며, 구문 분석에만 영향을 주고 쿼리 최적화나 쿼리 실행에는 영향을 주지 않습니다.SET QUOTED_IDENTIFIER
takes effect at Transact-SQLTransact-SQL parse-time and only affects parsing, not query optimization or query execution.
최상위 수준의 임시 일괄 처리를 위해 QUOTED_IDENTIFIER에 대한 세션의 현재 설정을 사용하여 구문 분석을 시작합니다.For a top-level ad-hoc batch parsing begins using the session's current setting for QUOTED_IDENTIFIER. 일괄 처리를 구문 분석하는 경우, 그 시점부터 발생한 SET QUOTED_IDENTIFIER
의 구문 분석 동작이 모두 변경되고 해당 설정이 세션에 대해 저장됩니다.As the batch is parsed any occurrence of SET QUOTED_IDENTIFIER
will change the parsing behavior from that point on, and save that setting for the session. 따라서 일괄 처리가 구문 분석되고 실행된 후 세션의 QUOTED_IDENTIFER 설정은 일괄 처리에서 마지막으로 발생한 SET QUOTED_IDENTIFIER
에 따라 설정됩니다.So after the batch is parsed and executed, the session's QUOTED_IDENTIFER setting will be set according to the last occurrence of SET QUOTED_IDENTIFIER
in the batch.
저장 프로시저의 정적 Transact-SQLTransact-SQL은 저장 프로시저를 만들거나 변경한 일괄 처리에 대해 적용된 QUOTED_IDENTIFIER 설정을 사용하여 구문 분석됩니다.Static Transact-SQLTransact-SQL in a stored procedure is parsed using the QUOTED_IDENTIFIER setting in effect for the batch that created or altered the stored procedure. SET QUOTED_IDENTIFIER
가 저장 프로시저 본문에 정적 Transact-SQLTransact-SQL로 표시될 때는 아무 효과도 없습니다.SET QUOTED_IDENTIFIER
has no effect when it appears in the body of a stored procedure as static Transact-SQLTransact-SQL.
sp_executesql
또는 exec()
를 사용하는 중첩된 일괄 처리의 경우 세션의 QUOTED_IDENTIFIER 설정을 사용하여 구문 분석이 시작됩니다.For a nested batch using sp_executesql
or exec()
, the parsing begins using the QUOTED_IDENTIFIER setting of the session. 중첩된 일괄 처리가 저장 프로시저 내부에 있는 경우 저장 프로시저의 QUOTED_IDENTIFIER 설정을 사용하여 구문 분석이 시작됩니다.If the nested batch is inside a stored procedure, parsing starts using the QUOTED_IDENTIFIER setting of the stored procedure. 중첩된 일괄 처리를 구문 분석하는 경우, 그 시점부터 발생하는 SET QUOTED_IDENTIFIER
의 구문 분석 동작이 모두 변경되지만 세션의 QUOTED_IDENTIFIER 설정은 업데이트되지 않습니다.As the nested batch is parsed, any occurrence of SET QUOTED_IDENTIFIER
will change the parsing behavior from that point on, but the session's QUOTED_IDENTIFIER setting will not be updated.
이 설정에 대한 현재 설정을 보려면 다음 쿼리를 실행합니다.To view the current setting for this setting, run the following query:
DECLARE @QUOTED_IDENTIFIER VARCHAR(3) = 'OFF';
IF ( (256 & @@OPTIONS) = 256 )
SET @QUOTED_IDENTIFIER = 'ON';
SELECT @QUOTED_IDENTIFIER AS QUOTED_IDENTIFIER;
사용 권한Permissions
PUBLIC
역할의 멤버 자격이 필요합니다.Requires membership in the PUBLIC
role.
예Examples
A.A. 따옴표 붙은 식별자 설정 및 예약 키워드 개체 이름 사용Using the quoted identifier setting and reserved word object names
다음 예에서는 SET QUOTED_IDENTIFIER
옵션을 ON
으로 설정하고 테이블 이름의 키워드를 큰따옴표로 묶어 예약 키워드 이름이 있는 개체를 생성 및 사용합니다.The following example shows that the SET QUOTED_IDENTIFIER
setting must be ON
, and the keywords in table names must be in double quotation marks to create and use objects that have reserved keyword names.
SET QUOTED_IDENTIFIER OFF
GO
-- Create statement fails.
CREATE TABLE "select" ("identity" INT IDENTITY NOT NULL, "order" INT NOT NULL);
GO
SET QUOTED_IDENTIFIER ON;
GO
-- Create statement succeeds.
CREATE TABLE "select" ("identity" INT IDENTITY NOT NULL, "order" INT NOT NULL);
GO
SELECT "identity","order"
FROM "select"
ORDER BY "order";
GO
DROP TABLE "SELECT";
GO
SET QUOTED_IDENTIFIER OFF;
GO
B.B. 작은따옴표 및 큰따옴표를 사용해 따옴표 붙은 식별자 설정 사용Using the quoted identifier setting with single and double quotation marks
다음 예에서는 SET QUOTED_IDENTIFIER
옵션이 ON
과 OFF
로 설정된 문자열 식에서 작은따옴표 및 큰따옴표가 사용되는 방법을 보여 줍니다.The following example shows the way single and double quotation marks are used in string expressions with SET QUOTED_IDENTIFIER
set to ON
and OFF
.
SET QUOTED_IDENTIFIER OFF;
GO
USE AdventureWorks2012;
IF EXISTS(SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_NAME = 'Test')
DROP TABLE dbo.Test;
GO
USE AdventureWorks2012;
CREATE TABLE dbo.Test (ID INT, String VARCHAR(30)) ;
GO
-- Literal strings can be in single or double quotation marks.
INSERT INTO dbo.Test VALUES (1, "'Text in single quotes'");
INSERT INTO dbo.Test VALUES (2, '''Text in single quotes''');
INSERT INTO dbo.Test VALUES (3, 'Text with 2 '''' single quotes');
INSERT INTO dbo.Test VALUES (4, '"Text in double quotes"');
INSERT INTO dbo.Test VALUES (5, """Text in double quotes""");
INSERT INTO dbo.Test VALUES (6, "Text with 2 """" double quotes");
GO
SET QUOTED_IDENTIFIER ON;
GO
-- Strings inside double quotation marks are now treated
-- as object names, so they cannot be used for literals.
INSERT INTO dbo."Test" VALUES (7, 'Text with a single '' quote');
GO
-- Object identifiers do not have to be in double quotation marks
-- if they are not reserved keywords.
SELECT ID, String
FROM dbo.Test;
GO
DROP TABLE dbo.Test;
GO
SET QUOTED_IDENTIFIER OFF;
GO
결과 집합은 다음과 같습니다.Here is the result set.
ID String
----------- ------------------------------
1 'Text in single quotes'
2 'Text in single quotes'
3 Text with 2 '' single quotes
4 "Text in double quotes"
5 "Text in double quotes"
6 Text with 2 "" double quotes
7 Text with a single ' quote
참고 항목See Also
CREATE DATABASE CREATE DATABASE
CREATE DEFAULT CREATE DEFAULT
CREATE PROCEDURE CREATE PROCEDURE
CREATE RULE CREATE RULE
CREATE TABLE CREATE TABLE
CREATE TRIGGER CREATE TRIGGER
CREATE VIEW CREATE VIEW
데이터 형식 Data Types
EXECUTE EXECUTE
SELECT SELECT
SET 문 SET Statements
SET ANSI_DEFAULTS SET ANSI_DEFAULTS
sp_rename sp_rename
데이터베이스 식별자Database Identifiers