Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/297.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 设置检索总运行时间的统计时间_C#_Sql Server - Fatal编程技术网

C# 设置检索总运行时间的统计时间

C# 设置检索总运行时间的统计时间,c#,sql-server,C#,Sql Server,通过连接c#中的InfoMessage事件,我可以从SQL中获得整个消息。但是,从该输出计算总运行时间的最佳方法是什么?当我在运行多个查询的存储过程上执行查询时,我只关心存储过程总共花了多长时间 我也尝试过通过变量计算它,但我得到: 必须声明标量变量“@StartDate” 干杯 输出: SQL Server解析和编译时间:CPU时间=0毫秒,运行时间=0 女士 SQL Server执行时间:CPU时间=0毫秒,运行时间=0毫秒 SQL Server执行时间:CPU时间=0毫秒,运行时间=9毫秒

通过连接c#中的InfoMessage事件,我可以从SQL中获得整个消息。但是,从该输出计算总运行时间的最佳方法是什么?当我在运行多个查询的存储过程上执行查询时,我只关心存储过程总共花了多长时间

我也尝试过通过变量计算它,但我得到:

必须声明标量变量“@StartDate”

干杯

输出:

SQL Server解析和编译时间:CPU时间=0毫秒,运行时间=0 女士

SQL Server执行时间:CPU时间=0毫秒,运行时间=0毫秒

SQL Server执行时间:CPU时间=0毫秒,运行时间=9毫秒。
SQL Server执行时间:CPU时间=0毫秒,运行时间=8毫秒

SQL Server执行时间:CPU时间=0毫秒,运行时间=8毫秒

SQL Server执行时间:CPU时间=0毫秒,运行时间=8毫秒。SQL 服务器解析和编译时间:CPU时间=0毫秒,运行时间=0毫秒

SQL Server解析和编译时间:CPU时间=47毫秒,运行时间= 47毫秒SQL Server执行时间:CPU时间=31毫秒,运行时间= 62毫秒

SQL Server执行时间:CPU时间=78毫秒,运行时间=110毫秒。
SQL Server执行时间:CPU时间=0毫秒,运行时间=7毫秒。
SQL Server执行时间:CPU时间=0毫秒,运行时间=0毫秒

c#:


string query=string.Format(“设置{0}上的统计时间设置统计时间关闭”,查询)

那么,你可以在应用程序中使用秒表,并测量经过的时间

//Import 
using System.Diagnostics;

//in your app
Stopwatch sw= new Stopwatch();
// initialize your connection and your sql command with stored procedure 
ws.Start();
YourSQLCommand.ExecuteNoneQuery()
ws.Stop();
Debug.Write("Time elapsed: {0}",
    ws.Elapsed);