Posts

Showing posts from August, 2009

Capturing PRINT statements from Stored Procedure in C#

publicclass StoredProcedure
{
private static ILog log = LogManager.GetLogger(MethodInfo.GetCurrentMethod().DeclaringType);

staticpublic 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 inparameters)
{
command.Parameters.Add(param);
}

try
{
command.ExecuteNonQuery();
}
catch (SqlException ex)
{

SQL Server Performance Improvements

Update Statistics UPDATESTATISTICS TABLE_NAME Rebuild Indexes ALTERINDEXALLON TABLE_NAME REBUILD