1

i want to import a MDX result set into Powershell using Invoke-ASCmd.

Import-Module SQLPS -DisableNameChecking
Import-Module SQLASCMDLETS

Push-Location SQLSERVER:\SQLAS\$ServerInstance\Default\Databases\$Database\Cubes\

$result = Invoke-ASCmd -Database $Database -Query $Query

Pop-Location

It fails with a System.OutOfMemoryException

  • The same MDX query works fine in SQL Server Management Studio.
  • There is still a lot of RAM free.
  • The Powershell runs in 64bit mode.
  • MaxMemoryPerShellMB is increased.
  • I am using SQL Server 2016 and Powershell 4

What's to do, to import large datasets from SQL Server Analysis Services using Powershell?

abbgrade
  • 548
  • 5
  • 19

1 Answers1

1

I found an workaround for this:

If you add a linked server to a SQL Server to the SSAS Cube you can execute it wrapped in SQL.

Invoke-Sqlcmd `
    -ServerInstance $ServerInstance `
    -Query "SELECT * FROM OpenQuery([SSAS_LinkedServer],'$( $query.Replace("'", "''" ) )')"
abbgrade
  • 548
  • 5
  • 19