哪个 SQL 查询是站点 运行?

Which SQL Query is the site running?

我公司的网站(内部网站或外部网站 - 有时是门户网站)return 某些结果(通过 SQL queries/commands 在后端系统中获得) .我 "m trying to find out which queries are being run in the background and how I could track back the query results onto the tables where they come from. How can I achieve that? I tried looking at the "source" 但在那里没有发现任何查询。后端使用 SQL 服务器如果重要的话。

如果您设置了隔离环境(即没有其他人可以同时访问这些页面)并且您有适当的 SQL 服务器访问权限,您可以查询 sys.dm_exec_query_stats table 打开每个页面以找出查询内容后 运行 获取该页面的数据。

您可以使用 SQL 服务器分析器。它将为您收集所有已执行的语句。对于测试环境或使用相对较少的东西,它是一个非常好的工具。对于频繁使用的生产环境,您可能会得到过多的结果,并且使用它也会产生轻微的性能开销。