You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Instructs the Query Optimizer to use statistical data instead of the initial values for all local variables when the query is compiled and optimized. This optimization includes parameters created with forced parameterization.
236
237
237
238
If you use OPTIMIZE FOR @variable_name = _literal\_constant_ and OPTIMIZE FOR UNKNOWN in the same query hint, the Query Optimizer will use the _literal\_constant_ specified for a specific value. The Query Optimizer will use UNKNOWN for the rest of the variable values. The values are used only during query optimization, and not during query execution.
238
-
239
+
240
+
QUERYTRACEON trace_flag
241
+
This option lets you to enable a plan-affecting trace flag only during single-query compilation. Like other query-level options, you can use it together with plan guides to match the text of a query being executed from any session, and automatically apply a plan-affecting trace flag when this query is being compiled. The QUERYTRACEON option is only supported for Query Optimizer trace flags that are documented in the table of "More information" section and in [Trace Flags](../database-console-commands/dbcc-traceon-trace-flags-transact-sql.md). However, this option will not return any error or warning if an unsupported trace flag number is used. If the specified trace flag is not one that affects a query execution plan, the option will be silently ignored.
242
+
243
+
More than one trace flag can be specified in the OPTION clause if QUERYTRACEON trace_flag_number is duplicated with different trace flag numbers.
244
+
239
245
PARAMETERIZATION { SIMPLE | FORCED }
240
246
Specifies the parameterization rules that the [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] Query Optimizer applies to the query when it's compiled.
241
247
@@ -596,7 +602,24 @@ WHERE City = 'SEATTLE' AND PostalCode = 98104
596
602
OPTION (RECOMPILE, USE HINT ('ASSUME_MIN_SELECTIVITY_FOR_FILTER_ESTIMATES', 'DISABLE_PARAMETER_SNIFFING'));
597
603
GO
598
604
```
599
-
605
+
### M. Using QUERYTRACEON HINT
606
+
The following example uses the QUERYTRACEON query hints. The example uses the [!INCLUDE[ssSampleDBobject](../../includes/sssampledbobject-md.md)] database. You can enable all plan-affecting hotfixes controlled by trace flag 4199 for a particular query using the following query:
607
+
608
+
```sql
609
+
SELECT*FROMPerson.Address
610
+
WHERE City ='SEATTLE'AND PostalCode =98104
611
+
OPTION (QUERYTRACEON 4199);
612
+
```
613
+
614
+
You can use multiple trace flags as well as in teh following query:
0 commit comments