Export (0) Print
Expand All
1 out of 4 rated this helpful - Rate this topic

Using Options in SQL Server

Microsoft SQL Server provides options that affect the result and performance of SQL statements. You can set these options in the following ways:

  • To set instance-wide configuration options, use the sp_configure stored procedure.

  • To set database-level options, use the ALTER DATABASE SET Options statement.

  • To set the database compatibility level, use the ALTER DATABASE Compatibility Level statement.

  • To specify batch-level options (SET options), use the SET statements, such as SET ANSI_PADDING and SET ANSI_NULLS.

    NoteNote

    Batch-level options are referred to as connection-level options in earlier versions of SQL Server and also in connections that have disabled Multiple Active Result Sets (MARS).

  • To specify statement-level options, such as query hints, table hints, and join hints, use the individual Transact-SQL statements. For more information, see Hints (Transact-SQL).

ODBC applications can specify connection options that control some of the ANSI SET options. Both the SQL Server Native Client OLE DB Provider for SQL Server and SQL Server Native Client ODBC driver set several SET options by default.

You should avoid changing SET options and setting them through the SET statements. Instead, we recommend that SET options be set at the connection level through the connection properties of ODBC or OLE DB. Alternatively, you can change SET option settings by using the sp_configure stored procedure.

sp_configure provides the option user options. This lets you change the default values of several SET options. Although user options appears to be an instance option, user options is a SET option.

When an option is supported at more than one level, the following hierarchy is imposed:

  1. A database option overrides an instance option.

  2. A SET option overrides a database option.

  3. A hint overrides a SET option.

NoteNote

SET options set within a dynamic SQL batch affect only the scope of that batch.

NoteNote

SET options, such as QUOTED_IDENTIFIER and ANSI_NULLS, are persisted with stored procedure definition and, therefore, take precedence over different values explicitly set for them.

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.