将Datetime值传递给tsql存储过程时,请参阅实际查询 [英] See the actual query when passing Datetime value to a tsql stored Procedure
问题描述
我有一个简单选择的存储过程,以及我将startdate作为datetime传入的cluse。是一种方法来查看实际执行的查询,如下所示:
I have a stored proc with simple select and where cluse that I pass startdate as datetime into. Is the a way to see the actual executed query as something like this
select id, startdate, ...
表a
其中startdate = 05/15/2019
where startdate = 05/15/2019
以下选择示例:
select id, startdate, ...
来自表a
其中startdate = @prmStartDate
where startdate = @prmStartDate
推荐答案
如果你想查看正在执行的内容,你可以使用:
If you want to see what is being executed you can use:
1 - SQL事件探查器(除非使用Azure SQL数据库) https://docs.microsoft.com/en-us/sql/tools/sql-server-profiler/start-sql-server-profiler?view=sql-server-2017
1 - SQL Profiler (unless using Azure SQL Database) https://docs.microsoft.com/en-us/sql/tools/sql-server-profiler/start-sql-server-profiler?view=sql-server-2017
2 - 扩展事件。 https://docs.microsoft.com/en-us/sql/relational-databases/extended-events/extended-events?view=sql-server-2017 功能;
2 - Extended events. https://docs.microsoft.com/en-us/sql/relational-databases/extended-events/extended-events?view=sql-server-2017
如果您拥有权限,使用SQL事件探查器可能会更容易/更快。只是尝试过滤掉你可以添加应用程序名称,登录名,数据库作为过滤器的内容。
Using SQL Profiler might be easier/quicker if you have the rights. Just try to filter out what you can like adding the application name, login name, database as filters.
如果你在SSMS中执行,只想看到 @ prmStartDate
你可以使用PRINT @ prmStartDate。
If you are executing in SSMS and just want to see the value of @prmStartDate you can use PRINT @prmStartDate.
这篇关于将Datetime值传递给tsql存储过程时,请参阅实际查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!