본 게시물은 개인적인 의견으로 작성되었으니 절대적인 정보가 아닐 수 있습니다. 참고만 하시고 궁금한 사항이 있으시면 연락주세요.

티스토리 뷰

SQL Server 에서 현재 세션의 SET OPTION 의 상태값을 확인하는 방법이 있다.

   

가장 단순하게 select @@options 을 실행하면 아래와 같이 결과를 볼 수 있다.

   

위 값은 아래 참고문서의 값을 모두 합한 값이다. 그래서 어느 옵션을 선택했는지 알 수가 없다.

이런 경우에 아래쿼리를 수행하면 확인이 가능하다.

   

SET STATISTICS IO, TIME OFF

DECLARE @options INT

SELECT @options = @@OPTIONS

   

PRINT @options

IF ( (1 & @options) = 1 ) PRINT 'DISABLE_DEF_CNST_CHK'

IF ( (2 & @options) = 2 ) PRINT 'IMPLICIT_TRANSACTIONS'

IF ( (4 & @options) = 4 ) PRINT 'CURSOR_CLOSE_ON_COMMIT'

IF ( (8 & @options) = 8 ) PRINT 'ANSI_WARNINGS'

IF ( (16 & @options) = 16 ) PRINT 'ANSI_PADDING'

IF ( (32 & @options) = 32 ) PRINT 'ANSI_NULLS'

IF ( (64 & @options) = 64 ) PRINT 'ARITHABORT'

IF ( (128 & @options) = 128 ) PRINT 'ARITHIGNORE'

IF ( (256 & @options) = 256 ) PRINT 'QUOTED_IDENTIFIER'

IF ( (512 & @options) = 512 ) PRINT 'NOCOUNT'

IF ( (1024 & @options) = 1024 ) PRINT 'ANSI_NULL_DFLT_ON'

IF ( (2048 & @options) = 2048 ) PRINT 'ANSI_NULL_DFLT_OFF'

IF ( (4096 & @options) = 4096 ) PRINT 'CONCAT_NULL_YIELDS_NULL'

IF ( (8192 & @options) = 8192 ) PRINT 'NUMERIC_ROUNDABORT'

IF ( (16384 & @options) = 16384 ) PRINT 'XACT_ABORT'

GO

   

   

[참고문서]

Evaluating Set Options

https://msdn.microsoft.com/en-us/library/ms189472.aspx

NSI_PADDING

1

Parallel Plan

2

FORCEPLAN

4

CONCAT_NULL_YIELDS_NULL

8

ANSI_WARNINGS

16

ANSI_NULLS

32

QUOTED_IDENTIFIER

64

ANSI_NULL_DFLT_ON

128

ANSI_NULL_DFLT_OFF

256

NoBrowseTable

   

Indicates that the plan does not use a work table to implement a FOR BROWSE operation.

512

TriggerOneRow

   

Indicates that the plan contains single row optimization for AFTER trigger delta tables.

1024

ResyncQuery

   

Indicates that the query was submitted by internal system stored procedures.

2048

ARITH_ABORT

4096

NUMERIC_ROUNDABORT

8192

DATEFIRST

16384

DATEFORMAT

32768

LanguageID

65536

UPON

   

Indicates that the database option PARAMETERIZATION was set to FORCED when the plan was compiled.

131072

ROWCOUNT

Applies To: SQL Server 2012 to SQL Server 2016

   

262144

 

댓글
최근에 올라온 글
최근에 달린 댓글
글 보관함
Total
Today
Yesterday