.net如何获取SQLServer中类似print的信息

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);
        }
    }
}

相关文章

SELECT a.*,b.dp_name,c.pa_name,fm_name=(CASE WHEN a.fm_n...
if not exists(select name from syscolumns where name=&am...
select a.*,pano=a.pa_no,b.pa_name,f.dp_name,e.fw_state_n...
要在 SQL Server 2019 中设置定时自动重启,可以使用 Window...
您收到的错误消息表明数据库 'EastRiver' 的...
首先我需要查询出需要使用SQL Server Profiler跟踪的数据库标...