Add new partition for analysis services by powershell
2012-12-23 23:52
603 查看
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.AnalysisServices");
$ASConnectionString = "Data Source = lewis-server ; Initial Catalog = CapitalDW ; Provider = MSOLAP; Impersonation Level = Impersonate " ;
$ASServer = New-object Microsoft.AnalysisServices.Server ;
$ASServer.connect($ASConnectionString);
##get-content Variable::ASConnectionString
##get-content Variable::ASServer
$DatabaseName = "CapitalDW"
$DatabaseID = $ASServer.Databases.FindByName($DatabaseName).ToString() ;
##get-content Variable::DatabaseID;
write-host "Databaseid:$DatabaseID";
##Cube
$dbName = $ASServer.Databases[$DatabaseID];
##get-content Variable::dbName
$cubeName = "Capital DW" ;
$cubeId = $dbName.cubes.FindByName($cubeName).ToString();
$measuregroupName = "Capital History" ;
$measuregroupid = $dbName.cubes[$cubeID].Measuregroups.FindByName($measuregroupName).ToString();
write-host "measuregroupid is : $measuregroupid ";
$newPartitionName = "Capital History 2012";
$sourceID = $dbName.cubes[$cubeID].Measuregroups.FindByName($measuregroupName).Partitions.FindByName("Capital History 2011").DataSource.ToString();
write-host "data source id : $sourceID";
$partition= $dbName.cubes[$cubeID].Measuregroups.FindByName($measuregroupName).Partitions.Add($newPartitionName);
$partition.Source = new-object Microsoft.AnalysisServices.QueryBinding( "$sourceID", "SELECT [dbo].[CapitalHistory].[itm_system_ky],[dbo].[CapitalHistory].[capital_value],[dbo].[CapitalHistory].[PK_Date]
FROM [dbo].[CapitalHistory]
WHERE pk_date>='2012-01-01' and pk_date<'2013-01-01'" );
$dbName.cubes[$cubeID].Measuregroups.FindByName($measuregroupName).Partitions.FindByName($newPartitionName).update();
write-host "new partition: $partition"
$ASConnectionString = "Data Source = lewis-server ; Initial Catalog = CapitalDW ; Provider = MSOLAP; Impersonation Level = Impersonate " ;
$ASServer = New-object Microsoft.AnalysisServices.Server ;
$ASServer.connect($ASConnectionString);
##get-content Variable::ASConnectionString
##get-content Variable::ASServer
$DatabaseName = "CapitalDW"
$DatabaseID = $ASServer.Databases.FindByName($DatabaseName).ToString() ;
##get-content Variable::DatabaseID;
write-host "Databaseid:$DatabaseID";
##Cube
$dbName = $ASServer.Databases[$DatabaseID];
##get-content Variable::dbName
$cubeName = "Capital DW" ;
$cubeId = $dbName.cubes.FindByName($cubeName).ToString();
$measuregroupName = "Capital History" ;
$measuregroupid = $dbName.cubes[$cubeID].Measuregroups.FindByName($measuregroupName).ToString();
write-host "measuregroupid is : $measuregroupid ";
$newPartitionName = "Capital History 2012";
$sourceID = $dbName.cubes[$cubeID].Measuregroups.FindByName($measuregroupName).Partitions.FindByName("Capital History 2011").DataSource.ToString();
write-host "data source id : $sourceID";
$partition= $dbName.cubes[$cubeID].Measuregroups.FindByName($measuregroupName).Partitions.Add($newPartitionName);
$partition.Source = new-object Microsoft.AnalysisServices.QueryBinding( "$sourceID", "SELECT [dbo].[CapitalHistory].[itm_system_ky],[dbo].[CapitalHistory].[capital_value],[dbo].[CapitalHistory].[PK_Date]
FROM [dbo].[CapitalHistory]
WHERE pk_date>='2012-01-01' and pk_date<'2013-01-01'" );
$dbName.cubes[$cubeID].Measuregroups.FindByName($measuregroupName).Partitions.FindByName($newPartitionName).update();
write-host "new partition: $partition"
相关文章推荐
- navigate and process Analysis Services by powershell
- Amazon Web Services发布AWS Tools For Windows PowerShell
- Computing for Data Analysis by Roger D. Peng @ Hopkins: Notes -- Simulation and Plotting
- Business analysis and SOA part 1 of 6: The benefits of business services [by Thomas Erl]
- 案例面世真题2:Cost-savings analysis for food services company
- Mar. 6, 15:00-17:00, 1493, "Strichartz analysis for Schrodinger and wave equation I" by Chong Chen
- Installing Reporting Services, Analysis Services and Enterprise Portal for AX 2009
- Analysis Services Partition Creation in SSIS
- 《Microsoft SQL Server 2008 Analysis Services Step by Step》学习笔记七:高级维度设计
- How to add a new "CustomAction" in ECB for a specific list
- 《Microsoft SQL Server 2008 Analysis Services Step by Step》学习笔记七:高级维度设计
- Configure Windows Firewall for SQL Server 2008 Analysis Services in Windows Server 2008 R2
- 《Microsoft SQL Server 2008 Analysis Services Step by Step》学习笔记十五:设计聚合(Aggregation)(下)
- select ROW_NUMBER() over(PARTITION BY InfoType order by NewsID)as rowid from News
- Configuring Kerberos for SharePoint 2007: Part 2 - Excel Services and SQL Analysis Services
- Add extra standby database to complete database migration to new servers with minimal outage
- How to add new partition in centos
- Computing for Data Analysis by Roger D. Peng @ Hopkins: Notes -- Data Types and Basic Operations
- Spark算子:RDD行动Action操作(4)–countByKey、foreach、foreachPartition、sortBy
- Add new resolution for Linux Mint / Ubuntu