SSAS: Updating Partitions

ref: http://dwbi1.wordpress.com/2010/09/29/updating-partition-source-sql/#comment-15356

I created an F# version, below. Note that my complete code updates the Slice property as well, but my code is too specific the the database to include here.:

[<EntryPoint>]
let main argv = 
    let adoConnStr = "Data Source={serverName};Catalog={DatabaseName}"
    let amo = new Microsoft.AnalysisServices.Server()
    amo.Connect(adoConnStr)
    let asdb = amo.Databases.FindByName("{DatabaseName}")
    let cube = asdb.Cubes.FindByName("{CubeName}")
    let mg = cube.MeasureGroups.FindByName("{MeasureGroupName}")
    let partitions = mg.Partitions
    
    //// this defines the partitions as a table in BIPOC, used by the view:
    //let parts = getPartitions psql

    let showpartitions = [ for p in partitions do yield ( ( p.Source :?> QueryBinding ).QueryDefinition  ) ]

    for pno in 0..(partitions.Count - 1) do 
        let p = partitions.[pno]
        let qb = p.Source :?> QueryBinding
        let newsql = sprintf "SELECT * FROM BIPOC.dbo.DRWFactPartition(%d) -- Updated:%s" (pno+1) (DateTime.Now.ToString())
        qb.QueryDefinition <- newsql
        // partitions.[pno].Slice <- parts.[pno].slice
        p.Update()
        // if p.State = AnalysisState.Unprocessed then p.Process()

    amo.Disconnect()
    0 // return an integer exit code
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s