using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Data;
using System.Text.RegularExpressions;
namespace ConsoleApplication16
{
class Program
{
static string connectionString = "data source=(local),2014;initial catalog=AdventureWorks2014;user id=?;password=?;";
static void Main(string[] args)
{
using (SqlConnection sqlcon = new SqlConnection(connectionString))
{
sqlcon.Open();
sqlcon.InfoMessage += new SqlInfoMessageEventHandler(OnReceivingInfoMessage);
/* 查询某个表上的索引碎片的详细信息 */
SqlCommand cmd = new SqlCommand("print 'Begin……'; DBCC SHOWCONTIG('[dbo].[ErrorLog]'); print 'End'", sqlcon);
cmd.CommandType = CommandType.Text;
cmd.ExecuteNonQuery();
}
Console.Read();
}
private static void OnReceivingInfoMessage(object sender, SqlInfoMessageEventArgs e)
{
Console.WriteLine(e.Message);
}
}
}