Exemple #1
0
        /// <summary>
        /// 查看源代码
        /// </summary>
        public static DataTable GetProcOrFuncText(string pfName)
        {
            string       sql = "exec sp_helptext @ProcFuncName";
            DbParameters p   = new DbParameters();

            p.Add("@ProcFuncName", pfName);

            return(DbComd.CreateSqlDataTable(sql, p));
        }
Exemple #2
0
        /// <summary>
        /// 查询服务器资源消耗情况、用户和进程的信息
        /// </summary>
        public static DataTable SPWho3(string spid)
        {
            try
            {
                string       spName = "sp_who3";
                DbParameters p      = new DbParameters();
                p.Add("@SessionID", spid);

                return(Dbl.Command.CreateDataTable(spName, p));
            }
            catch (Exception ex)
            {
                throw new Exception("\n--" + DateTime.Now.ToString() + "SPWho3() 报错:----\n" + ex.Message + "--end--\n");
                return(null);
            }
        }
Exemple #3
0
        /// <summary>
        /// 查看进程正在执行的SQL语句
        /// </summary>
        public DataTable GetInputBuffer(int spid)
        {
            try
            {
                string sql = @"
                    DBCC InputBuffer(@SPID)
                ";

                DbParameters p = new DbParameters();
                p.Add("@SPID", spid);

                return(Dbl.Command.CreateSqlDataTable(sql, p));
            }
            catch (Exception ex)
            {
                throw new Exception("\n--" + DateTime.Now.ToString() + " GetInputBuffer(int) 报错:----\n" + ex.Message + "--end--\n");
                return(null);
            }
        }
Exemple #4
0
        /// <summary>
        /// 查看指定数据库的连接信息
        /// </summary>
        public static DataTable GetDataProcess(string dataName)
        {
            try
            {
                string sql = @"
                    SELECT * FROM master.dbo.sysprocesses WHERE DB_NAME(dbid) = @DataName
                ";

                DbParameters p = new DbParameters();
                p.Add("@DataName", dataName);

                return(Dbl.Command.CreateSqlDataTable(sql, p));
            }
            catch (Exception ex)
            {
                throw new Exception("\n--" + DateTime.Now.ToString() + " GetDataProcess(string) 报错:----\n" + ex.Message + "--end--\n");
                return(null);
            }
        }
Exemple #5
0
        /// <summary>
        /// 查看特定数据库的日志文件大小
        /// </summary>
        public static DataTable GetLogSpace(string dataName)
        {
            try
            {
                string       sql = @"
                Begin
                    --创建临时表--
                    CREATE TABLE tempdb.dbo.#tbl_DBLogSpaceUsage  
                    (  
                          DatabaseName NVARCHAR(128) ,  
                          LogSize NVARCHAR(25) ,  
                          LogSpaceUsed NVARCHAR(25) ,  
                          [Status] TINYINT  
                    )
                    INSERT INTO dbo.#tbl_DBLogSpaceUsage EXEC ('DBCC SQLPERF(LogSpace)');
                                
                    --查询特定数据库的结果-- 
                    SELECT  DatabaseName ,  
                            LogSize AS LogSizeInMB ,  
                            LogSpaceUsed LogspaceUsed_In_Percent ,  
                            [Status]  
                    FROM tempdb.dbo.#tbl_DBLogSpaceUsage  
                    WHERE Databasename = @DataBaseName   

                    --删除临时表--
                    DROP TABLE tempdb.dbo.#tbl_DBLogSpaceUsage  
                End             
            ";
                DbParameters p   = new DbParameters();
                p.Add("@DataBaseName", dataName);

                return(DbComd.CreateSqlDataTable(sql, p));
            }
            catch (System.Exception ex)
            {
                throw new Exception("\n---- " + DateTime.Now.ToString() + " GetLogSpace() 报错:----\n" + ex.Message + "--end--\n");
                return(null);
            }
        }