使用 Powershell 创建 SSAS 2008 多维数据集分区?

发布于 12-22 07:16 字数 46 浏览 8 评论 0原文

我们如何使用 Powershell 创建 SSAS 2008 多维数据集分区?

How can we create SSAS 2008 cube partitions using Powershell?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

少女净妖师2024-12-29 07:16:15

这会向 Adventure Works DW 2008R2 多维数据集添加一个分区(特别是 Adventure Works 多维数据集中的 Internet Customers 度量值组):

$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()

您必须更改顶部的变量以及对 Microsoft.AnalysisServices.dll 的引用 assembly,但除此之外,这将非常有效。

诀窍是对更改的对象调用 Update(),然后对整个数据库本身调用。

如果您还想处理新分区,可以在 $srv.Disconnect 之前添加以下行:

$srv.Databases[$catalog].Cubes[$cube].MeasureGroups[$measure_group].Partitions[$new_partition].Process()

您可以了解有关分析管理对象 (AMO) 的更多信息 此处

This adds a partition to the Adventure Works DW 2008R2 cube (specifically the Internet Customers measure group in the Adventure Works cube):

$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()

You'll have to change variables up top, and the reference to the Microsoft.AnalysisServices.dll assembly, but other than that, this will work peachy keen.

The trick is to call Update() on the object changed and then on the whole database itself.

If you'd like to process the new partition, as well, you can do that with the following line before $srv.Disconnect:

$srv.Databases[$catalog].Cubes[$cube].MeasureGroups[$measure_group].Partitions[$new_partition].Process()

You can learn more about Analysis Management Objects (AMO) here.

我的痛♀有谁懂2024-12-29 07:16:15

看看这个: PowerSSAS

它没有显式添加分区支持,因此您可能需要制作一个XMLA 代码片段用于添加分区,然后使用 PowerSSAS 将其推送到 SSAS 服务器。

Check out this: PowerSSAS

It doesn't have explicit add partition support, so you'll probably have to craft an XMLA snippet to do the add partition and then use PowerSSAS to push it to the SSAS server.

岁月染过的梦2024-12-29 07:16:15

您可以使用 :

Microsoft.AnalysisServices.Deployment [ASdatabasefile] 
{[/s[:logfile]] | [/a] | [[/o[:output_script_file]] [/d]]}

通过 powershell 部署您的多维数据集 AS。

you can use :

Microsoft.AnalysisServices.Deployment [ASdatabasefile] 
{[/s[:logfile]] | [/a] | [[/o[:output_script_file]] [/d]]}

to deploy your cube AS with powershell.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文