IF OBJECT_ID('tempdb..#work_to_do') IS NOT NULL
DROP TABLE tempdb..#work_to_do BEGIN TRY --BEGIN TRAN use yourdbname
Все, что мне когда-либо пригодилось
IF OBJECT_ID('tempdb..#work_to_do') IS NOT NULL
DROP TABLE tempdb..#work_to_do BEGIN TRY --BEGIN TRAN use yourdbname
ALTER PROCEDURE [dbo].[Print_Unlimited] @String NVARCHAR(MAX)AS
BEGIN
BEGIN TRY ---------------------------------------------------------------------------------
DECLARE @CurrentEnd BIGINT; /* track the length of the next substring */ DECLARE @Offset TINYINT; /* tracks the amount of offset needed */ SET @String = replace(replace(@String, CHAR(13) + CHAR(10), CHAR(10)), CHAR(13), CHAR(10))
WHILE LEN(@String) > 1 BEGIN IF CHARINDEX(CHAR(10), @String) BETWEEN 1 AND 4000 BEGIN SET @CurrentEnd = CHARINDEX(CHAR(10), @String) -1 SET @Offset = 2 END ELSE BEGIN SET @CurrentEnd = 4000 SET @Offset = 1 END PRINT SUBSTRING(@String, 1, @CurrentEnd) SET @String = SUBSTRING(@String, @CurrentEnd + @Offset, LEN(@String)) END /*End While loop*/
--------------------------------------------------------------------------------- END TRY BEGIN CATCH DECLARE @ErrorMessage VARCHAR(4000) SELECT @ErrorMessage = ERROR_MESSAGE() RAISERROR(@ErrorMessage,16,1) END CATCHEND
Param($ServerName="server_name")$loadInfo = [Reflection.Assembly]::LoadWithPartialName("Microsoft.AnalysisServices")$server = New-Object Microsoft.AnalysisServices.Server$server.connect($ServerName)if ($server.name -eq $null) { Write-Output ("Server '{0}' not found" -f $ServerName) break } $sum=0foreach ($d in $server.Databases ) { Write-Output ("Database: {0}; Status: {1}; Size: {2}MB" -f $d.Name, $d.State, ($d.EstimatedSize/1024/1024).ToString("#,##0") ) $sum=$sum+$d.EstimatedSize/1024/1024 } $SizeGB=$Sum/1024 write-host 'Sum of Database = '$sum 'MB'Write-host 'Total Size of Cube Databases =' $SizeGB 'GB'