- Learn T-SQL Querying
- Pedro Lopes Pam Lahoud
- 164字
- 2021-06-24 14:38:13
Forced parameterization
If an application tends to generate many ad hoc queries, and there is no way to modify the application to parameterize the queries, the Parameterization database option can be changed to Forced. When Forced Parameterization is turned on, SQL Server will replace ALL literal values in ALL ad hoc queries with parameter markers. Take the example of the following query executed in the AdventureWorks sample database:
SELECT LastName, FirstName, MiddleName
FROM Person.Person
WHERE PersonType = N'EM' AND BusinessEntityID IN (5, 7, 13, 17, 19);
This query would be automatically parameterized under Forced Parameterization, as follows:
(@1 nchar(2), @2 int, @3 int, @4 int, @5 int, @6 int) SELECT LastName, FirstName, MiddleName
FROM Person.Person
WHERE PersonType = @1 AND BusinessEntityID IN (@2, @3, @4, @5, @6);
This has the benefit of increasing the reusability of all ad hoc queries, but there are some risks to parameterizing all literal values in all queries, which will be discussed later in section The importance of parameters.
推薦閱讀
- 網(wǎng)絡(luò)服務(wù)器架設(shè)(Windows Server+Linux Server)
- Apache Spark Deep Learning Cookbook
- Supervised Machine Learning with Python
- 嵌入式操作系統(tǒng)
- 智能生產(chǎn)線的重構(gòu)方法
- Learning ServiceNow
- MATLAB-Simulink系統(tǒng)仿真超級學(xué)習手冊
- 三菱FX/Q系列PLC工程實例詳解
- Python文本分析
- 人工智能:智能人機交互
- 運動控制系統(tǒng)(第2版)
- 中國戰(zhàn)略性新興產(chǎn)業(yè)研究與發(fā)展·數(shù)控系統(tǒng)
- 智能+:制造業(yè)的智能化轉(zhuǎn)型
- 計算機應(yīng)用基礎(chǔ)學(xué)習指導(dǎo)與練習(Windows XP+Office 2003)
- Generative Adversarial Networks Projects