sql-server - SQL Server 2005 中的拦截和重写查询

标签 sql-server sql-server-2005

我们有一个基于 SQL Server 2005 构建的应用程序,我们无法控制该应用程序。我们最近发现该应用程序正在向 SQL 发送一些非常低效的 SELECT 查询,从而导致数据库出现严重的容量问题。我知道正确的解决方案是破解应用程序的代码并更改查询,但由于我不会详细说明这将需要很长时间。有什么方法可以拦截 SQL Server 上的这个特定查询并有选择地将其重写为更优化的查询吗?

最佳答案

您可以使用这种方法。 它对我来说就像一个魅力:)

Rather than attempting to intercept and modify SQL calls originating from the application, perhaps you can instead implement an abstraction layer without changing the application's SQL. For example, if you can modify the DSN or login connection string for the application, then connsider the following. Let's assume the current database is [A]. Create a new database [B] that contains views and functions (but not tables) with the same name as what is in [A], then modify them to reference the tables in [A]. Add whatever additional joins, filtering, etc. are needed to implement your (what I'm assuming) row based security. Then, modify the application DSN to use database [B] instead of [A].

link

关于sql-server - SQL Server 2005 中的拦截和重写查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1036553/

相关文章:

SQL Server 临时表

sql - 定义表关系后,SQL Server 2005 是否更快?

mysql - 将记录从 MySQL 数据库导入 MS SQL 的最佳解决方案(每小时)

SQL Server 2000 和 2005 中用户定义函数的性能

sql - 努力避免 RBAR!如何将相关表上的插入关联为基于集合的操作?

c# - SQL Server 2008 - 使用多个关键字和分页的全文搜索

sql - 如何在 Azure Runbook 中运行 SQL 批处理?

asp.net - SQL Server 2012 授予从 ASP.net 访问 sys.dm_os_ring_buffers

sql - 选择分页连接行以可靠地限制不同的相关行

sql - 未在另一个存储过程中执行的存储过程