Pun*_*thi 7 powershell ssas cube ssas-2008
我们如何使用Powershell创建SSAS 2008多维数据集分区?
这将为Adventure Works DW 2008R2多维数据集添加一个分区(特别是Adventure Works多维数据集中的Internet客户度量组):
$server_name = "localhost"
$catalog = "Adventure Works DW 2008R2"
$cube = "Adventure Works"
$measure_group = "Fact Internet Sales"
$old_partition = "Customers_2004"
$new_partition = "Customers_2009"
$old_text = "'2008"
$new_text = "'2009"
[Reflection.Assembly]::LoadFile("C:\Program Files\Microsoft SQL Server\100\SDK\Assemblies\Microsoft.AnalysisServices.DLL")
$srv = new-object Microsoft.AnalysisServices.Server
$srv.Connect("Data Source=" + $server_name)
$new_part = $srv.Databases[$catalog].Cubes[$cube].MeasureGroups[$measure_group].Partitions[$old_partition].Clone()
$new_part.ID = $new_partition
$new_part.Name = $new_partition
$new_part.Source.QueryDefinition = $new_part.Source.QueryDefinition.Replace($old_text, $new_text)
$srv.Databases[$catalog].Cubes[$cube].MeasureGroups[$measure_group].Partitions.Add($new_part)
$srv.Databases[$catalog].Cubes[$cube].MeasureGroups[$measure_group].Partitions[$new_partition].Update()
$srv.Databases[$catalog].Update()
$srv.Disconnect()
Run Code Online (Sandbox Code Playgroud)
你必须在顶部更改变量,以及对Microsoft.AnalysisServices.dll程序集的引用,但除此之外,这将很好用.
诀窍是调用Update()更改的对象,然后调用整个数据库本身.
如果您还想处理新分区,可以使用以下行执行此操作$srv.Disconnect:
$srv.Databases[$catalog].Cubes[$cube].MeasureGroups[$measure_group].Partitions[$new_partition].Process()
Run Code Online (Sandbox Code Playgroud)
您可以在此处了解有关Analysis Management Objects(AMO)的更多信息.
| 归档时间: |
|
| 查看次数: |
1653 次 |
| 最近记录: |