運行時間編譯的 Transact-SQL 語句可能會向惡意攻擊公開應用程式。 使用 時sp_executesql,您應該將查詢參數化。 如需詳細資訊,請參閱SQL 插入。 Transact-SQL 語法慣例 Syntax SQL Server、Azure SQL 資料庫、Azure SQL 受控執行個體、Azure Synapse Analytics 和 Analytics Platform System (PDW) 的語法。
运行时编译的 Transact-SQL 语句可能会向恶意攻击公开应用程序。 使用sp_executesql时应参数化查询。 有关详细信息,请参阅SQL 注入。 Transact-SQL 语法约定 语法 SQL Server、Azure SQL 数据库、Azure SQL 托管实例、Azure Synapse Analytics 和 Analytics Platform System(PDW)的语法。
sp_executesql executes a Transact-SQL statement or batch that can be reused many times, or one that is built dynamically.
运行时编译的 Transact-SQL 语句可能会向恶意攻击公开应用程序。 使用sp_executesql时应参数化查询。 有关详细信息,请参阅SQL 注入。 Transact-SQL 语法约定 语法 SQL Server、Azure SQL 数据库、Azure SQL 托管实例、Azure Synapse Analytics 和 Analytics Platform System(PDW)的语法。
在批处理、名称作用域和数据库上下文方面,sp_executesql 与 EXECUTE 的行为相同。sp_executesql stmt 参数中的 Transact-SQL 语句或批处理在执行 sp_executesql 语句时才编译。随后,将编译 stmt 中的内容,并将其作为执行计划运行。该执行计划独立于名为 sp_executesql 的批处理的执行计划。sp_executesql 批处理不...
建议您在执行字符串时,使用sp_executesql存储过程而不要使用 EXECUTE 语句。由于此存储过程支持参数替换,因此sp_executesql比 EXECUTE 的功能更多;由于 SQL Server 更可能重用sp_executesql生成的执行计划,因此sp_executesql比 EXECUTE 更有效。 自包含批处理 ...
不允许使用字符常量。如果指定了 Unicode 常量,则必须使用N 作为前缀。例如,Unicode 常量 N’sp_who’ 是有效的,但是字符常量 ‘sp_who’ 则无效。字符串的大小仅受可用数据库服务器内存限制。在 64 位服务器中,字符串大小限制为 2 GB,即 nvarchar(max) 的最大大小。
正如本主题前面的“语法”部分中所述,必须按特定顺序输入 sp_executesql 参数。 如果这些参数的输入顺序不正确,则会显示一条错误消息。 在批处理、名称作用域和数据库上下文方面,sp_executesql 与 EXECUTE 的行为相同。 sp_executesql @stmt 参数中的 Transact-SQL 语句或批处理在执行 sp_executesql 语句时才会进...
建议您在执行字符串时,使用 sp_executesql 存储过程而不要使用 EXECUTE 语句。由于此存储过程支持参数替换,因此 sp_executesql 比EXECUTE 的功能更多;由于 SQL Server 更可能重用 sp_executesql 生成的执行计划,因此 sp_executesql 比EXECUTE 更有效。 自包含批处理 当sp_executesql 或EXECUTE 语句执行字符串时,...
在批处理、名称作用域和数据库上下文方面,sp_executesql 与 EXECUTE 的行为相同。sp_executesql stmt 参数中的 Transact-SQL 语句或批处理在执行 sp_executesql 语句时才编译。随后,将编译 stmt 中的内容,并将其作为执行计划运行。该执行计划独立于名为 sp_executesql 的批处理的执行计划。sp_executesql 批处理不...