SQL : Table size
SELECT TOP 1000 a2.name AS [tablename], (a1.reserved + ISNULL(a4.reserved,0))* 8 AS reserved, a1.rows as row_count, a1.data * 8 AS data, (CASE WHEN (a1.used + ISNULL(a4.used,0)) > a1.data THEN...
View ArticleSQL : Database File Size on used space
select a.FILEID, [FILE_SIZE_MB]=convert(decimal(12,2),round(a.size/128.000,2)), [SPACE_USED_MB]=convert(decimal(12,2),round(fileproperty(a.name,'SpaceUsed')/128.000,2)),...
View ArticleSQL : Reindex all tables
SET ANSI_NULLS ON SET ANSI_PADDING ON SET ANSI_WARNINGS ON SET ARITHABORT ON SET CONCAT_NULL_YIELDS_NULL ON SET QUOTED_IDENTIFIER ON SET NUMERIC_ROUNDABORT OFF EXEC SP_MSForEachTable "Print...
View ArticleSQL : Remove maintenance plan history from MSDB database
USE msdb ALTER TABLE [dbo].[sysmaintplan_log] DROP CONSTRAINT [FK_sysmaintplan_log_subplan_id]; ALTER TABLE [dbo].[sysmaintplan_logdetail] DROP CONSTRAINT [FK_sysmaintplan_log_detail_task_id];...
View ArticleScript to shrink all user databases
--Script to shrink all databases declare @db varchar(255) declare c cursor for select name from sys.databases where is_read_only=0 and state=0 and name not in ('master','model','tempdb','msdb') open c...
View ArticleSize of all objects (Tables and Indexes) on a database
WITH StatsDetails as ( SELECT obj.name, i.name AS IndexName, s.index_id, sum(s.row_count ) as [RowCount], SUM(s.used_page_count) *8 AS ObjectSizeKb, sum(s.in_row_data_page_count)*8 as RowDataSizeKb,...
View ArticleSummary of SQL table components (Data, index, lob)
SELECT '['+sch.name+'].['+obj.name+']', max(s.row_count ) as [RowCount], SUM(s.used_page_count) *8 AS ObjectSizeKb, sum(s.in_row_used_page_count)*8 as DataSizeKb, sum(case when s.index_id in (0,1)...
View ArticleInstall Windows Updates on Windows Server 2008 R2 Core
Set updateSession = CreateObject("Microsoft.Update.Session") Set updateSearcher = updateSession.CreateupdateSearcher() WScript.Echo "Searching for updates..." & vbCRLF Set searchResult = _...
View ArticleList of SQL server instance in SpiceWorks
Create a new report with ‘Build this report using SQL’ checked and copy following SQL to generate report SELECT Distinct devices.name as ComputerName ,Software.Name as SqlVersionInstalled...
View ArticleUpdate name of Cisco Ip Phone In SpiceWorks
Update devices set name=replace(description,'Cisco IP ','') where device_type='VoipDevice' and description like 'Cisco IP Phone %'; select name,manufacturer,model,server_name as Address from devices...
View Article
More Pages to Explore .....