c# - 使用 SqlCommand 在存储过程中获取底层执行查询
问题描述
假设我有一个存储过程(示例如下)
CREATE OR ALTER PROCEDURE test
AS
BEGIN
SELECT * FROM sys.tables;
WAITFOR DELAY '01:00'
SELECT * FROM sys.tables
END
GO;
我有一个 SQLCommand 的 ac# 调用,它运行一个存储过程,如下所示
using (var connection = new SqlConnection(connectionString)){
connection.Open();
using(var command = new SqlCommand("test", connection)){
command.CommandType = CommandType.StoredProcedure;
command.ExecuteNonQuery();
}
}
有没有办法让我获得当前在存储过程中执行的底层 sql 语句?
我想要的是能够记录“SELECT * FROM sys.tables”、“WAITFOR DELAY '01:00'”等。
解决方案
推荐阅读
- ios - 多个文件的iOS openurl
- arrays - 使用 Postman 为对象数组发送 GET 请求
- c++ - 系统地缩放 C++ 函数的返回结构
- ckeditor - 无界的 CkEditor5 视图值
- python - 如何使用“onehot_enc”实现朴素贝叶斯算法?
- symfony - Nginx symfony““try_files”指令中的参数数量无效”
- javascript - 当存在具有特定名称的键时,将对象推入数组中
- android - 添加依赖项 CardView 和 RecylerView 时出现 Gradle 错误
- java - Java 转换器空元素
- angular6 - Splice 返回已删除的元素,而不是返回所有其他未删除的元素