在SSMS中,我已连接到SSAS表格多维数据集。当我查看属性屏幕时,我看到最后处理的时间戳为11/24/2015 2:59:20 PM
。
如果我使用SELECT LAST_DATA_UPDATE FROM $system.MDSchema_Cubes
,我会看到11/25/2015 12:13:28 PM
的时间戳(如果我调整时区)。
如果我打开我的多维数据集中某个表的分区屏幕,我会看到最后一个已处理的时间戳是11/25/2015 12:13:28 PM
,它与DMV中的值匹配。
我想要BISM的Last Processed时间戳,即数据库属性屏幕中的时间戳,而不是以后碰巧处理的分区中的时间戳。
有没有办法以编程方式获得此功能?
答案 0 :(得分:0)
您可以使用可以从here下载的Analysis Services存储过程程序集。
获得与Analysis Server版本对应的程序集文件后,通过SSMS连接到您的实例。
New Assembly...
-
with member [Measures].[LastProcessed] as ASSP.GetCubeLastProcessedDate()
select [Measures].[LastProcessed] on 0
from [Armetales DWH]
请告诉我这是否可以帮助您。
答案 1 :(得分:0)
在查看Analysis Services存储过程程序集中的代码之后,我能够整合一个PowerShell脚本,该脚本获得了我正在寻找的日期。这是代码:
#we want to always stop the script if any error occurs
$ErrorActionPreference = "Stop"
$error.Clear()
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.AnalysisServices") | Out-Null
$databases = @('BISM1', 'BISM2')
$servers = @('Server1\BISM', 'Server2\BISM')
function Get-BISMLastProcessed
{
param(
[string] $connStr
)
Begin {
$server = New-Object Microsoft.AnalysisServices.Server
$server.Connect($connStr)
}
Process {
Try {
$database = $server.Databases.GetByName($_)
Write-Host " Database [$($database.Name)] was last processed $($database.LastProcessed)"
}
Catch [System.Exception] {
Write-Host $Error[0].Exception
}
Finally {
if ($database -ne $null) {
$database.Dispose()
}
}
}
End {
$server.Dispose()
}
}
foreach ($server in $servers) {
$connectStr = "Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=BISM1;Data Source=$server"
Write-Host "Server [$server]"
$databases | Get-BISMLastProcessed $connectStr
Write-Host "----------------"
}
结果是:
Server [Server1\BISM]
Database [BISM1] was last processed 11/30/2015 12:25:48
Database [BISM2] was last processed 12/01/2015 15:53:56
----------------
Server [Server2\BISM]
Database [BISM1] was last processed 11/30/2015 12:19:32
Database [BISM2] was last processed 11/02/2015 23:46:34
----------------