Tuesday, 23 October 2012

List all Objects per Filegroup

The following query can be used to list all obejcts per filegroup including the allocated data size.
SELECT ds.name AS DataSpaceName ,au.type_desc AS AllocationDesc ,au.total_pages / 128 AS TotalSizeMB ,au.used_pages / 128 AS UsedSizeMB ,au.data_pages / 128 AS DataSizeMB ,sch.name AS schemaName ,obj.type_desc AS ObjectType ,obj.name AS ObjectName ,idx.type_desc AS IndexType ,idx.name AS IndexName FROM sys.data_spaces AS ds INNER JOIN sys.allocation_units AS au ON ds.data_space_id = au.data_space_id INNER JOIN sys.partitions AS PA ON (au.type IN (1, 3) AND au.container_id = PA.hobt_id) OR (au.type = 2 AND au.container_id = PA.partition_id) INNER JOIN sys.objects AS obj ON PA.object_id = obj.object_id INNER JOIN sys.schemas AS sch ON obj.schema_id = sch.schema_id LEFT JOIN sys.indexes AS idx ON PA.object_id = IDX.object_id AND PA.index_id = idx.index_id WHERE obj.type_desc NOT IN('SYSTEM_TABLE', 'INTERNAL_TABLE') ORDER BY ds.name ,sch.name ,obj.name ,idx.name

Monday, 8 October 2012

SSIS - Overiding Package Variable Configuration Values on the Command Line

To overide SSIS pacakge variable values set in configuration files with those specified on the command line the following can be added to the command line.
/Set \Package.Variables[User::start_date].Properties[Value];2012-09-09

Powershell - Get a Specific Line from a Text File

To retrieve the specific line of a text file in powershell use the following command:
Get-content -Path myfile.txt | Select-Object -Index 60614
To retrieve the first 10 rows use:
Get-content -Path myfile.txt | Select-Object -First 10
To retrieve the last10 rows use:
Get-content -Path myfile.txt | Select-Object -Last 10