Viewing current optimizer settings

sp_options allows you to view the current optimizer settings for these options:

sp_options queries the sysoptions fake table, which stores information about each set option, its category, and its current and default settings. sysoptions also contains a bitmap that provides detailed information for each option

The syntax for sp_options is:

sp_options [ [show | help
                         [, option_name | category_name |null
                              [, dflt | non_dflt | null 
                                  [, spid] ] ] ] ]

where:

For example, to display the current optimizer settings shown below, enter:

sp_options show
Category: Query Tuning
name                      
          currentsetting     defaultsetting         scope
--------------------------------------------------------------------
          ------------------ ---------------------  ---------
optlevel           
          ase_default        ase_current            3
optgoal          
          allrows_mix        allrows_mix            3
opttimeoutlimit  
          10                 10                     2
repartition_degree  
          1                  1                      2
scan_parallel_degree  
          0                  1                      2
resource_granularity  
          10                 10                     2

. . .

outer_join_costing: outer join row counts and histogramming
          0                  0                      7
join_duplicate_estimates: avoid overestimates of dups in joins
          0                  0                      7
imdb_costing: 0 PIO costing for scans for in-memory database
          1                  1                      7
auto_temptable_stats: auto generation of statistics for #temptables
          0                  0                      7
use_mixed_dt_sarg_under_specialor: allow special OR in case of mixed . . . 
          0                  0                      7
timeout_cart_product: timeout queries involving cartesian product and more . . .
          0                  0                      7

(81 rows affected)

See Adaptive Server Reference Manual: Procedures.

Any user can query sysoptions:

You can also use string manipulation or a cast. For example, if an option is numeric, you can query sysoptions by entering:

if (isnumeric(currentsetting))
	select@int_val = convert(int, currentsetting)
	...
else
	select@char_val = currentsetting
	...

For more infomation about sysoptions, see Adaptive Server Reference Manual: Tables.