Analysis Management Objects (AMO) 是SQL Server SSAS的对象模型库,通过它可以方便的对SSAS里的对象进行访问及控制,包括Cube,DataSource, DataSourceView, Partition, Measure, Dimension, Assembly, Role以及DataMining对象等。要使用它,必须在机器上找到SSAS的安装路径..\MicrosoftSQL Server\90\SDK\Assemblies,把目录中的Microsoft.AnalysisServices.Dll文件加载到项目的Reference列表中,AMO对象就是通过这个Dll文件进行访问的。

首先要添加引用using Microsoft.AnalysisServices;

以下是测试用C#从SSAS中获取部分信息的源码:(代码中已经包含了较多的解释)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;using Microsoft.AnalysisServices;namespace AMOTest
{class Program{static void Main(string[] args){string ConnecteString = "Data Source =ServerName; Provider=msolap";Server SSASServer = new Server();SSASServer.Connect(ConnecteString);List<Database> OutDatabase = GetDatabaseCollection(SSASServer);//show all database on the serverConsole.WriteLine("-------------Databse-------------------------------");for (int i = 0; i < OutDatabase.Count; i++){Console.WriteLine(OutDatabase[i].Name.ToString());}//show the Cube of a databaseConsole.WriteLine("---------------Cube--------------------------------");List<Cube> OutCube = GetCubeCollection(OutDatabase[0]);for (int i = 0; i < OutCube.Count; i++){Console.WriteLine(OutCube[i].Name.ToString());}//show all Roles of one databaseConsole.WriteLine("---------------Roles_database-------------------------");List<Role> OutRole = GetRolescollection(OutDatabase[0]);Console.WriteLine(OutRole[0].Members.Count);//for (int i = 0; i < OutRole[0].Members.Count; i++)              //to show the detial of the role Members//{//    Console.WriteLine(OutRole[0].Members[i].Name);//}//show all Roles of one cubeConsole.WriteLine("---------------Roles_Cube----------------------------");List<Role> OutRole2 = GetRolescollection2(OutCube[0]);Console.WriteLine(OutRole2[0].Members.Count);//for (int i = 0; i < OutRole2[0].Members.Count; i++)//{//    Console.WriteLine(OutRole2[0].Members[i].Name);         //to show the detial of the role Members//}Console.Read();}//get the list of the database namestatic public List<Database> GetDatabaseCollection(Server server){List<Database> collectdb = new List<Database>();foreach (Database db in server.Databases){collectdb.Add(db);}return collectdb;}//get the list of a database cube namestatic public List<Cube> GetCubeCollection(Database db){List<Cube> collectcube = new List<Cube>();foreach (Cube cube in db.Cubes){collectcube.Add(cube);}return collectcube;}//get the list of the database rolesstatic public List<Role> GetRolescollection(Database db){List<Role> collectRoles = new List<Role>();foreach (Role cp in db.Roles){collectRoles.Add(cp);}return collectRoles;}//get the list of the cube Rolesstatic public List<Role> GetRolescollection2(Cube cube){List<Role> collectionRoles = new List<Role>();foreach (CubePermission cp in cube.CubePermissions){collectionRoles.Add(cp.Role);}return collectionRoles;}}
}

这里需要说明的是,当我获取Database的Roles和Cube的Roles值时,做了一个对比,他们的值是相同的。这可能的情况是,在Database中Cube只有一个,或者因为Cube隶属于database,他们的Roles值是相同的。

如下是运行完的截图:

通过AMO获取SQL Server SSAS信息(C#)相关推荐

  1. ssas从mysql获取数据库_通过AMO获取SQL Server SSAS信息

    Analysis Management Objects (AMO) 是SQL Server SSAS的对象模型库,通过它可以方便的对SSAS里的对象进行访问及控制,包括Cube,DataSource, ...

  2. 获取SQL Server数据库增长和收缩事件的详细信息

    It is essential for the DBA to need to ensure the SQL Server database performance. Performance tunin ...

  3. sql 获取数据库字段信息_使用DBATools获取SQL数据库详细信息

    sql 获取数据库字段信息 In the series of articles on DBATools, (see TOC at the bottom) we are exploring useful ...

  4. Always On可用性组中SQL Server统计信息

    SQL Server统计信息简介 (Introduction to SQL Server Statistics) SQL Server Statistics are an essential part ...

  5. 使用系统视图发现SQL Server实例信息

    介绍 (Introduction) Out of the box, SQL Server comes with a substantial and – release by release – eve ...

  6. SQL Server统计信息以及如何在SQL中执行更新统计信息

    This article gives a walk-through of SQL Server Statistics and different methods to perform SQL Serv ...

  7. t–sql pl–sql_不正确SQL Server统计信息– SQL查询性能的杀手–基本知识

    t–sql pl–sql 什么是SQL Server统计信息? (What are SQL Server statistics?) SQL Server statistics are a collec ...

  8. 全废话SQL Server统计信息(2)——统计信息基础

    接上文:http://blog.csdn.net/dba_huangzj/article/details/52835958 我想在大地上画满窗子,让所有习惯黑暗的眼睛都习惯光明--顾城<我是一个 ...

  9. SQL Server统计信息:问题和解决方式

    SQL Server统计信息:问题和解决方式 参考文章: (1)SQL Server统计信息:问题和解决方式 (2)https://www.cnblogs.com/yutingliuyl/p/7257 ...

最新文章

  1. 元数据驱动的微服务架构(上)
  2. 数据模拟工具wgsim
  3. Oracle学习笔记之三,Oracle 11g数据库的启动与关闭
  4. EFCore笔记之异步查询
  5. 统计某一范围内所有的是K的倍数或者含有K的整数
  6. Educoder Basemap和Seaborn 第2关:Seaborn图形介绍
  7. 最新android工程目录下armeabi-v7a,armeabi的具体含义,有什么区别
  8. 算法学习系列(MCMC):MCMC采样
  9. ios键盘遮挡输入框问题
  10. gz是什么意思饭圈_网络语BE是什么意思 饭圈用GE含义出处是哪里还有哪些类似表达...
  11. Sulley fuzzer learning
  12. Linux操作系统——切换到root用户及其他用户
  13. vivado 2018.2官方下载
  14. 关于OLEDB参数化查询【.net】
  15. 服务器机器人维修技术,维修机器人
  16. MIT线性代数笔记四 矩阵的LU分解
  17. unity开发 斗地主算法—提示AI(提示出牌)
  18. 怎样从盘面看主力动向
  19. 蓝桥杯Python刷题
  20. Games102 学习笔记

热门文章

  1. java毕业设计汽车配件管理系统(附源码、数据库)
  2. 群邑智库:2019年跨年晚会分析
  3. diskpart clean命令清空分区表后的数据恢复
  4. 如何科学选择推广关键词(转)
  5. Springboot异步多线程编程
  6. node-npm 设置淘宝镜像
  7. 领导讲话演讲稿,5个模板,即拿即用!(建议收藏)
  8. 【c++】atan2()和atan()函数
  9. arcgis10.0及以上版本,使用arcpy加载在arctoolbox中批量转换MXD空间版本(只能从高转低)
  10. python代码~考研祝福