Microsoft Docs

Deploying Data Mining Models

This article provides step‑by‑step guidance for deploying a data mining model from a development environment to a production Analysis Services instance.

Step 1 — Prepare the Model

Ensure that the mining model is fully trained and validated in your development instance.

  • Review model performance metrics.
  • Document the input columns, processing options, and algorithm settings.
  • Export the model to a .bim file using SQL Server Data Tools (SSDT).

Step 2 — Create a Mining Structure

In the target Analysis Services database, create a mining structure that matches the model definition.

CREATE MINING STRUCTURE [AdventureWorks_MiningStructure]
(
    [CustomerAge] FLOAT,
    [AnnualIncome] FLOAT,
    [PurchaseHistory] LONG,
    ...
)
USING [Microsoft.Mining.Cluster];

Step 3 — Deploy the Model

Deploy the model using either SQL Server Management Studio (SSMS) or a PowerShell script.

Import-Module SqlServer
$server = "myprodserver"
$database = "AdventureWorksDW"
$modelPath = "C:\Models\CustomerChurnModel.bim"

Invoke-ASCmd -ServerInstance $server -Database $database -InputFile $modelPath

Step 4 — Verify Deployment

Confirm that the model is available and functional.

SELECT *
FROM $system.mining_models
WHERE model_name = 'CustomerChurnModel';

Run a test prediction to ensure correct results.

Sample Deployment Script

# DeployMiningModel.ps1
Import-Module SqlServer
$targetServer = "prod-ssas01"
$targetDatabase = "RetailDW"
$miningModelFile = "C:\Deploy\RetailCustomerModel.bim"

Write-Host "Deploying model to $targetServer\$targetDatabase..."
Invoke-ASCmd -ServerInstance $targetServer -Database $targetDatabase -InputFile $miningModelFile
Write-Host "Deployment complete."

For more advanced scenarios, see Automation of Model Deployments.