gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-03 01:35:45 30 4
gpt4 key购买 nike

我们有一个基于 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/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com