Database Reference
In-Depth Information
ning the wizard 24 times per day (for hourly partitions) is too labor intensive. Further-
more, creating partitions might only be a small portion of the scheduled job streams.
The sequence of scheduled jobs could collect data from various source systems,
populate a relational warehouse, and manage Analysis Services objects as new data
becomes available. Even if you're not a programmer, don't despair, as you can auto-
mate the creation of partitions with relatively easy commands using the PowerShell
scripting language. Of course Powershell is not the only language you can use to
create partitions; feel free to experiment with a language of your choice. Here are
sample Powershell commands for creating a new partition based on an existing mod-
el partition. You can customize the script for your environment:
# Script to create a new partition based on
existing partition
#load the Analysis Services assembly first so
you can instantiate Analysis Services server
object(# MicrosoftAnalysisServices.dll #will be
found under your Analysis Services installation
#folder:
[Reflection.Assembly]::LoadFrom("E:\Program
Files\Microsoft SQL
Server\110\SDK\Assemblies\Microsoft.AnalysisServices.dll")|out-null
$instance="Julia-PC\SQL2012"
$amoServer= new-object
Microsoft.AnalysisServices.Server
#connect to the instance:
$amoServer.Connect($instance)
#connect to the database, cube and measure
group of interest:
$db=$amoServer.databases.GetByName("ssas_cookbook_chapter3")
$cube =
$db.cubes.GetByName("AdventureWorksSample")
$mg=$cube.MeasureGroups.GetByName("Fact
Reseller Sales")
#clone the existing partition:
$new_partition =
$mg.partitions.GetByName("Reseller Sales
2006").clone()
Search WWH ::




Custom Search