Posts

Showing posts from August, 2009

Capturing PRINT statements from Stored Procedure in C#

public class StoredProcedure { private static ILog log = LogManager.GetLogger(MethodInfo.GetCurrentMethod().DeclaringType); static public void Execute (DBSqlPath path , int connectionTimeout, int commandTimeout, string storedProcedureName, SqlParameter[] parameters ) { SqlInfoMessageHandler handler = new SqlInfoMessageHandler(); using (DBConn conn = new DBConn( path , connectionTimeout)) { conn.OpenConnection(); conn.SqlConnection.InfoMessage += handler.connection_InfoMessage; SqlCommand command = new SqlCommand(storedProcedureName, conn.SqlConnection); command.CommandType = CommandType.StoredProcedure; command.CommandTimeout = commandTimeout; foreach (SqlParameter param in parameters ) { command. Parameters . Add (param); } try { command.ExecuteNonQuery();

SQL Server Performance Improvements

Update Statistics UPDATE STATISTICS TABLE_NAME Rebuild Indexes ALTER INDEX ALL ON TABLE_NAME REBUILD