What is a dynamic SQL query, and when would I want to use one? I'm using SQL Server 2005.
什么是动态SQL查询,何时我想使用它?我正在使用SQL Server 2005。
3 个解决方案
#1
6
Here's a few articles:
这里有几篇文章:
- Introduction to Dynamic SQL
- 动态SQL简介
- Dynamic SQL Beginner's Guide
- 动态SQL初学者指南
From Introduction to Dynamic SQL:
从简介到动态SQL:
Dynamic SQL is a term used to mean SQL code that is generated programatically (in part or fully) by your program before it is executed. As a result it is a very flexible and powerful tool. You can use dynamic SQL to accomplish tasks such as adding where clauses to a search based on what fields are filled out on a form or to create tables with varying names.
动态SQL是一个术语,用于表示程序在执行之前以编程方式(部分或全部)生成的SQL代码。因此,它是一个非常灵活和强大的工具。您可以使用动态SQL来完成任务,例如根据表单上填写的字段向搜索添加where子句或创建具有不同名称的表。
#2
3
Dynamic SQL is SQL generated by the calling program. This can be through an ORM tool, or ad-hoc by concatenating strings. Non-dynamic SQL would be something like a stored procedure, where the SQL to be executed is predefined. Not all DBA's will let you run dynamic SQL against their database due to security concerns.
动态SQL是由调用程序生成的SQL。这可以通过ORM工具实现,也可以通过连接字符串进行临时实现。非动态SQL类似于存储过程,其中要执行的SQL是预定义的。由于安全问题,并非所有DBA都允许您针对其数据库运行动态SQL。
#3
1
A dynamic SQL query is one that is built as the program is running as opposed to a query that is already (hard-) coded at compile time.
动态SQL查询是在程序运行时构建的查询,而不是在编译时已经(硬)编码的查询。
The program in question might be running either on the client or application server (debatable if you'd still call it 'dynamic') or within the database server.
有问题的程序可能在客户端或应用程序服务器上运行(如果您仍称其为“动态”,则可辩论)或在数据库服务器中运行。
#1
6
Here's a few articles:
这里有几篇文章:
- Introduction to Dynamic SQL
- 动态SQL简介
- Dynamic SQL Beginner's Guide
- 动态SQL初学者指南
From Introduction to Dynamic SQL:
从简介到动态SQL:
Dynamic SQL is a term used to mean SQL code that is generated programatically (in part or fully) by your program before it is executed. As a result it is a very flexible and powerful tool. You can use dynamic SQL to accomplish tasks such as adding where clauses to a search based on what fields are filled out on a form or to create tables with varying names.
动态SQL是一个术语,用于表示程序在执行之前以编程方式(部分或全部)生成的SQL代码。因此,它是一个非常灵活和强大的工具。您可以使用动态SQL来完成任务,例如根据表单上填写的字段向搜索添加where子句或创建具有不同名称的表。
#2
3
Dynamic SQL is SQL generated by the calling program. This can be through an ORM tool, or ad-hoc by concatenating strings. Non-dynamic SQL would be something like a stored procedure, where the SQL to be executed is predefined. Not all DBA's will let you run dynamic SQL against their database due to security concerns.
动态SQL是由调用程序生成的SQL。这可以通过ORM工具实现,也可以通过连接字符串进行临时实现。非动态SQL类似于存储过程,其中要执行的SQL是预定义的。由于安全问题,并非所有DBA都允许您针对其数据库运行动态SQL。
#3
1
A dynamic SQL query is one that is built as the program is running as opposed to a query that is already (hard-) coded at compile time.
动态SQL查询是在程序运行时构建的查询,而不是在编译时已经(硬)编码的查询。
The program in question might be running either on the client or application server (debatable if you'd still call it 'dynamic') or within the database server.
有问题的程序可能在客户端或应用程序服务器上运行(如果您仍称其为“动态”,则可辩论)或在数据库服务器中运行。