Permalink
Browse files

Get list of active trace flags

  • Loading branch information...
gboge committed Apr 19, 2017
1 parent 61b9e68 commit eeb23c01d6f7428cbe5d5ab74c2f49457188fe1b
Showing with 15 additions and 0 deletions.
  1. +15 −0 KServer.cs
View
@@ -84,6 +84,21 @@ FROM sys.databases
return d.ExecuteWithResults(sql).Tables[0];
}
+ /// <summary>
+ /// Get list of active trace flags
+ /// </summary>
+ /// <param name="s">your smo server</param>
+ /// <returns>a datatable with the list of databases</returns>
+ public static DataTable GetActiveTraceFlags(this smo.Server s)
+ {
+ smo.Database d = s.Databases["master"];
+ return d.ExecuteWithResults(@"CREATE TABLE #traceflag (traceflag int, status int, global int, session int)
+INSERT INTO #traceflag
+EXEC ('DBCC TRACESTATUS(-1)')
+SELECT * FROM #traceflag
+DROP TABLE #traceflag").Tables[0];
+ }
+
#endregion
#region SQL Server Versions

0 comments on commit eeb23c0

Please sign in to comment.