WMI Script to retrieve SSRS Configurations

For retrieving the SQL Server Reporting Services configurations using custom program in C# or .NET we need to use WMI (Windows Management Instrumentation) script. The process involves the following steps.

RETRIEVING WMI NAMESPACE FOR SSRS
For retrieving the WMI namespace we write the following function.

 
public static string GetNamespace(string machineName)
 {
   string rSroot = @"root\Microsoft\SqlServer\ReportServer";
   string strNamespace = "";
   System.Management.ManagementClass mc = new ManagementClass(new    ManagementScope(@"root\Microsoft\SqlServer\ReportServer"), new ManagementPath("__namespace"), null);
            foreach (ManagementObject ns in mc.GetInstances())
            {
                if (ns["Name"].ToString().Contains("RS_"))
                {
                    rSroot = rSroot + "\\" + ns["Name"].ToString();
                }
            }

            System.Management.ManagementClass mc1 = new ManagementClass(new ManagementScope(rSroot), new ManagementPath("__namespace"), null);
            foreach (ManagementObject ns in mc1.GetInstances())
            {
                if (ns["Name"].ToString().Contains("v"))
                {
                    rSroot = rSroot + "\\" + ns["Name"].ToString();
                }
            }
            System.Management.ManagementClass mc2 = new ManagementClass(new ManagementScope(rSroot), new ManagementPath("__namespace"), null);
            foreach (ManagementObject ns in mc2.GetInstances())
            {
                if (ns["Name"].ToString().Contains("Admin"))
                {
                    rSroot = rSroot + "\\" + ns["Name"].ToString();
                }
            }
            strNamespace = rSroot;
            return strNamespace;
        }

RETRIEVING WMI CLASS FOR SSRS
The above function accepts system name/ IP address as parameter. Once we get the namespace for reporting service, we pass the same to the below function to get the associated class which contains the report server configuration.

public static string GetClass(string strNamespace)
        {
            string ClassName = "";
            ManagementClass newRSClass = new ManagementClass(strNamespace);
            EnumerationOptions options = new EnumerationOptions();
            options.EnumerateDeep = true; // set to false if only the root classes
            ManagementObjectCollection mo = newRSClass.GetSubclasses(options);
            foreach (ManagementObject ob in mo)
            {
                if (ob["__Class"].ToString().Contains("MSRep"))
                    ClassName = ob["__Class"].ToString();
              
            }
            return ClassName;
        }

RETRIEVING SSRS CONFIGURATION PROPERTIES
Once we have retrieved the Class Name then we refer to class and try to get the configuration info through the below code.

public static void ReportServerProperties(string strNamespace, string ClassName)
        {
            ManagementClass serverClass;
            ManagementScope scope;
            try
            {
                scope = new ManagementScope(strNamespace);
                scope.Connect();
                serverClass = new ManagementClass(ClassName);
                serverClass.Get();
                if (serverClass == null)
                    throw new Exception("No class found");
                ManagementObjectCollection instances = serverClass.GetInstances();
                foreach(ManagementObject mo in instances)
                {
                    Console.WriteLine("Instances detected");
                    PropertyDataCollection props = mo.Properties;
                    foreach (PropertyData propData in props)
                    {
                        string name = propData.Name;
                        string value = propData.Value != null ? propData.Value.ToString() : "NULL";
                        Console.WriteLine(name + " " + value);
                    }
                }

            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }           
        }
 

 

Reporting Service Architecture




The Reporting Service Architecture Components 

  • Report Manager :- It is a web application which stores and manages report,report models,report parts, folders, subscriptions, security and schedules.
  • Report Server :- This is a web service which exposes all the methods for report management to Report Manager/Custom applications which can consume it and can create UI for report management.
  • Report Server DB/Temp DB :- The report server database keeps all the report paths, schedule info and other utility information like schedule,subscription details in DB tables. The report Server temp db keeps the session related information like SessionData, Snapshot, temp catalog and temp datasource etc.
  • Report Designer :- This is the tool used to design the report. For SSRS we have Report Builder and Business Intelligence Development Studio tools used to design reports.
  • Data Source :- Data Source is used to connect to the source from where data needs to be presented using report.
  • Report Processor :- The report processor is the engine which processes the report/subscription request.

SSAS 2008R2 Storage Modes

In SQL Server Analysis Services 2008, we have three storage mode options available to us: Relational Online Analytical Processing (ROLAP), Multidimensional Online Analytical Processing (MOLAP) and Hybrid Online Analytical Processing (HOLAP). 

Relational Online Analytical Processing (ROLAP)

The ROLAP storage mode allows the detail data and aggregations to be stored in the relational database. We have to be very careful on the Database design if we are using the ROLAP as the cube queries data directly from the Database and may cause performance issue if the Database design is not proper.

Benifits
Since the data is kept in the relational database instead of on the OLAP server, we can view the
data in almost real time. Also, since the data is kept in the relational database, it allows for much larger amounts of data, which can mean better scalability. Low latency.

Problems
- Poor query performance as all the data stays in the Database.
- We need to have permanent connection of the cube with the Database so the data can be pulled out from there.

Multidimensional Online Analytical Processing (MOLAP)

With MOLAP storage, the data and aggregations are stored in a multidimensional format, compressed and optimized for performance. Here data is aggregated and stored in the Cube.

Benifits  
- Query Performance will be much faster as aggregates are pre-calculated and stored in the Cube.

Problems 
- Large size data returning queries can cause problem as everything is on memory.
- We need to process the cubes to get the latest updated data.
- Additional amount of data is wasted as one copy of the fact and dimension data resides in the Database and another in the Cube.

Hybrid Online Analytical Processing (HOLAP)

HOLAP is a combination of MOLAP and ROLAP. HOLAP stores the detail data in the relational database but stores the aggregations in multidimensional format. Because of this, the aggregations will need to be processed when changes are occur.

Performance: not as slow as ROLAP, but not as fast as MOLAP. If, however, you were only querying aggregated data or using a cached query, query performance would be similar to MOLAP. But when we need to get that detail data, performance is closer to ROLAP 

Benifits 
- Cube  size is smaller than the MOLAP.
- Query time is faster than ROLAP.
- Process time is smaller than MOLAP.

Problems 
- Query performance can go down if more detailed data required.
 
   

MS BI Syllabus


Microsoft Business Intelligence Course Syllabus

SSRS – SQL Server Reporting Services

 Getting Started

1. Understanding Reporting (Authoring,Management,Delivery)
2. Installing Reporting (Native Mode, SharePoint Integration mode)
3. Building your first report

 Authoring Reports

1. Developing Basic Reports (RDL,wizard,designer,datasource,dataset,formatting)
2. Working with expressions (expression to calculate value, Agg functions, exp for objects)
3. Organizing Data (Data Regions, Table, Matrix, Chart, List)
4. Advance Report (Parameter, drill down, drill through, links,
5. Report Model (Data Source, Data Source View, Model , Report Builder 3.0)

 Managing Report ( Report Manager)

1. Managing Content (deploying report, folders, linked reports, datasources, value etc)
2. Managing Security (Item Level , Site navigation, localhost – sql)
3. Managing Server Config (Config Manager, Report Manager, Report Server DB)

 Delivering Report

1. Accessing Report (Viewing Report, Report History, saving in diff format, printing)
2. Rendering Report ( online – mhtml, doc – pdf,tiff, data – excel,csv)
3. Managing Subscription (Standard subscription, Data driven subscription)

 Programming Report

1. Using Code.
2. Using Reporting Service
3. Custom Assembly

SSIS – SQL Server Integration Services

 Getting Started With SSIS

1. Introduction
2. Import and Export wizard
3. Building first package
4. Components

 Designing Packages

1. Extracting and Loading Data
2. Using Dataflow Transformations
3. Control Flow
4. Scripting Task
5. Debugging
6. Managing Package Execution

 Managing Packages

1. Detecting and Handling Processing errors.
2. Configurations and deployment.

 Applying SSIS to DW

1. DW Concepts
2. Populating DW structures
3. General Principles 

SSAS – SQL Server Analysis Services


Getting Started

1. Business Intelligence and Data Warehousing
2. OLAP and Analysis Services
3. First Cube

Design Fundamentals

1. Data Source and Data Source Views (Creating and Modifying)
2. SSAS Cube (Creating and Modifying)
3. Dimensions (Creating and Modifying , hierarchies , assigning dimension to cube)
4. Measure Group (Creating, adding measure group and measure)
5. Adding KPIs (Goal,Status,Trend), Actions (URL,DrillThrough,Reporting) etc.
6. Storage Modes – MOLAP,ROLAP,HOLAP
7. Perspective
8. Translations.

Production Management

1. Deployment (impersonation mode, processing cube)
2. Partitions (partitions), Aggregations (Aggregations Design , Usage based optimization)
3. MDX - introduction

T-SQL LEAD LAG and SUM function based query

  Query on T-SQL window clause Below is the sales table Order_Date Name Product SubCategory ...