<#@ template debug="false" hostspecific="false" language="C#" #>
<#@ output extension=".partitions" #>
<Cube xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ddl2="http://schemas.microsoft.com/analysisservices/2003/engine/2"
xmlns:ddl2_2="http://schemas.microsoft.com/analysisservices/2003/engine/2/2"
xmlns:ddl100_100="http://schemas.microsoft.com/analysisservices/2008/engine/100/100"
xmlns:ddl200="http://schemas.microsoft.com/analysisservices/2010/engine/200"
xmlns:ddl200_200="http://schemas.microsoft.com/analysisservices/2010/engine/200/200"
xmlns:ddl300="http://schemas.microsoft.com/analysisservices/2011/engine/300"
xmlns:ddl300_300="http://schemas.microsoft.com/analysisservices/2011/engine/300/300"
xmlns:ddl400="http://schemas.microsoft.com/analysisservices/2012/engine/400"
xmlns:ddl400_400="http://schemas.microsoft.com/analysisservices/2012/engine/400/400"
xmlns:dwd="http://schemas.microsoft.com/DataWarehouse/Designer/1.0"
dwd:design-time-name="d9434059-83fc-481e-b3e2-1efc4430eb86"
xmlns="http://schemas.microsoft.com/analysisservices/2003/engine">
<ID>MyCube</ID>
<MeasureGroups>
<MeasureGroup>
<ID>MyMeasureGroup</ID>
<Partitions>
<#
DateTime
start = Convert.ToDateTime("2014-09-01");
DateTime
end = Convert.ToDateTime("2015-09-30");
while(start <= end)
{
Guid partitionId = Guid.NewGuid();
Guid queryId= Guid.NewGuid();
string
partitionName = "MyMeasureGroup_" + start.ToString("yyyy_MM_dd");
string
queryText = @"SELECT * FROM MyTable WHERE startDate = '" + start.ToString("yyyy-MM-dd") + "'";
#>
<Partition dwd:design-time-name="<#=partitionId.ToString() #>">
<ID><#=partitionName
#></ID>
<Name><#=partitionName #></Name>
<CreatedTimestamp>0001-01-01T00:00:00Z</CreatedTimestamp>
<LastSchemaUpdate>0001-01-01T00:00:00Z</LastSchemaUpdate>
<LastProcessed>0001-01-01T00:00:00Z</LastProcessed>
<State>Unprocessed</State>
<Source
xsi:type="QueryBinding" dwd:design-time-name="<#=queryId.ToString() #>">
<DataSourceID>PecoAMIMDR</DataSourceID>
<QueryDefinition><#=queryText#></QueryDefinition>
</Source>
<StorageMode>Molap</StorageMode>
<CurrentStorageMode>Molap</CurrentStorageMode>
<ProcessingMode>Regular</ProcessingMode>
</Partition>
<#
start
= start.AddDays(1);
}
#>
</Partitions>
</MeasureGroup>
</MeasureGroups>
</Cube>
The resulting code create 2 years of daily partitions in a few seconds. I then replaced the contents of this file with the partitions file in the project. The solution needed to be closed and reopened in order to accept the changes properly. Later, I changed the build process of the T4 Template project to replace the partitions file in a post build step. The learning curve on this is not so steep so I encourage you to give it a go.