Skip to content

Clive Roberts

SQL DBA

Menu
  • Server Setup Scritps
  • mssql
  • Scripts
  • MS Notification Services

Category: Server Setup Scritps

Sp_who3

October 31, 2016
| No Comments
| Server Setup Scritps

USE [master] GO /****** Object: StoredProcedure [dbo].[sp_who3] Script Date: 24/06/2016 15:29:28 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE PROCEDURE [dbo].[sp_who3] AS ——————————————————————————————————– — mimics sp_who2 with query text — SPID , Status , Login , HostName , BlkBy , DBName , Command , CPUTime , DiskIO , LastBatch , ProgramName , SPID…

Read More »

Posted in Server Setup Scritps

Trace_Status

October 31, 2016
| No Comments
| Server Setup Scritps

DBCC TRACESTATUS (-1 ); ————————————– —–TRACEON ————————————– DBCC TRACEON (1117, -1 ); DBCC TRACEON (1118, -1 ); DBCC TRACEON (1222, -1 ); DBCC TRACEON (3226, -1 ); DBCC TRACEON (4199, -1 ); ————————————– —–TRACEOFF ————————————– –DBCC TRACEOFF — (1117, -1 — ); –DBCC TRACEOFF — (1118, -1 — ); –DBCC TRACEOFF — (1222, -1 —…

Read More »

Posted in Server Setup Scritps

Job_Integrity_Check

October 31, 2016
| No Comments
| Server Setup Scritps

USE [msdb]; GO /****** Object: Job [USER Integrity Check main] Script Date: 19/04/2016 14:06:30 ******/ BEGIN TRANSACTION; DECLARE @ReturnCode INT; SELECT @ReturnCode = 0; /****** Object: JobCategory [Database Maintenance] Script Date: 19/04/2016 14:06:30 ******/ IF NOT EXISTS ( SELECT name FROM msdb.dbo.syscategories WHERE name = N’Database Maintenance’ AND category_class = 1 ) BEGIN EXEC @ReturnCode…

Read More »

Posted in Server Setup Scritps

Database_Integrity_Check

October 31, 2016
| No Comments
| Server Setup Scritps

USE [master]; GO /****** Object: StoredProcedure [dbo].[DatabaseIntegrityCheck] Script Date: 19/02/2016 09:58:06 ******/ –DROP PROCEDURE [dbo].[DatabaseIntegrityCheck]; –GO /****** Object: StoredProcedure [dbo].[DatabaseIntegrityCheck] Script Date: 19/02/2016 09:58:06 ******/ SET ANSI_NULLS ON; GO SET QUOTED_IDENTIFIER ON; GO CREATE PROCEDURE [dbo].[DatabaseIntegrityCheck] @Databases NVARCHAR(MAX), @CheckCommands NVARCHAR(MAX)= ‘CHECKDB’, @PhysicalOnly NVARCHAR(MAX)= ‘N’, @NoIndex NVARCHAR(MAX)= ‘N’, @ExtendedLogicalChecks NVARCHAR(MAX)= ‘N’, @TabLock NVARCHAR(MAX)= ‘N’, @FileGroups NVARCHAR(MAX)=…

Read More »

Posted in Server Setup Scritps

Index_job

October 31, 2016
| No Comments
| Server Setup Scritps

USE [msdb]; GO /****** Object: Job [USER INDEXES] Script Date: 18/02/2016 16:54:31 ******/ BEGIN TRANSACTION; DECLARE @ReturnCode INT; SELECT @ReturnCode = 0; /****** Object: JobCategory [[Uncategorized (Local)]] Script Date: 18/02/2016 16:54:31 ******/ IF NOT EXISTS ( SELECT name FROM msdb.dbo.syscategories WHERE name = N'[Uncategorized (Local)]’ AND category_class = 1 ) BEGIN EXEC @ReturnCode = msdb.dbo.sp_add_category…

Read More »

Posted in Server Setup Scritps

Create_Backup_Objects_and_Jobs

October 31, 2016
| No Comments
| Server Setup Scritps

/* Back up the master, msdb, and model databases to ensure that you can roll back to a previous configuration if problems occur. master: This database hosts system-level information. Back up this database regularly. model: You need to back up the template database only after you have made modifications. Because changes to the template database…

Read More »

Posted in Server Setup Scritps

Index_Optimize

October 31, 2016
| No Comments
| Server Setup Scritps

USE [MASTER]; GO SET ANSI_NULLS ON; GO SET QUOTED_IDENTIFIER ON; GO CREATE PROCEDURE dbo.CommandExecute @Command NVARCHAR(MAX), @CommandType NVARCHAR(MAX), @Mode INT, @Comment NVARCHAR(MAX)= NULL, @DatabaseName NVARCHAR(MAX)= NULL, @SchemaName NVARCHAR(MAX)= NULL, @ObjectName NVARCHAR(MAX)= NULL, @ObjectType NVARCHAR(MAX)= NULL, @IndexName NVARCHAR(MAX)= NULL, @IndexType INT= NULL, @StatisticsName NVARCHAR(MAX)= NULL, @PartitionNumber INT= NULL, @ExtendedInfo XML= NULL, @LogToTable NVARCHAR(MAX), @Execute NVARCHAR(MAX) AS…

Read More »

Posted in Server Setup Scritps

Create_Operator_and_Standard_Alerts

October 31, 2016
| No Comments
| Server Setup Scritps

USE [msdb]; GO IF ( SELECT 1 FROM [dbo].[sysoperators] WHERE name = ‘DBA_Alerts’ ) IS NULL BEGIN EXEC msdb.dbo.sp_add_operator @name = N’DBA_Alerts’, @enabled = 1, @pager_days = 0, @email_address = N’DBA_Alerts@dwf.co.uk’; END; ELSE BEGIN PRINT ‘Operator Already Exists’; END; GO USE [msdb]; GO IF ( SELECT 1 FROM [dbo].[sysalerts] WHERE name = ‘Corruption Alert 823…

Read More »

Posted in Server Setup Scritps

Setup_SQL_Server_Agent_Alerting_System

October 31, 2016
| No Comments
| Server Setup Scritps

USE [msdb]; GO EXEC master.dbo.xp_instance_regwrite N’HKEY_LOCAL_MACHINE’, N’SOFTWARE\Microsoft\MSSQLServer\SQLServerAgent’, N’UseDatabaseMail’, N’REG_DWORD’, 1; GO EXEC master.dbo.xp_instance_regwrite N’HKEY_LOCAL_MACHINE’, N’SOFTWARE\Microsoft\MSSQLServer\SQLServerAgent’, N’DatabaseMailProfile’, N’REG_SZ’, N’SQL_Alerting’; GO EXEC msdb.dbo.sp_set_sqlagent_properties @email_save_in_sent_folder = 1; GO –RESTART SQL SERVER AGENT

Read More »

Posted in Server Setup Scritps

Setup_TempDB_Files

October 31, 2016
| No Comments
| Server Setup Scritps

–Add TempDB Files to number of prcessors (up to 8) DECLARE @dbname VARCHAR(200); DECLARE @datafilename VARCHAR(200); DECLARE @logfilename VARCHAR(200); DECLARE @cpucount SMALLINT; DECLARE @datafilepath VARCHAR(200); DECLARE @logilepath VARCHAR(200); DECLARE @datasizeMB INT; DECLARE @logsizeMB INT; DECLARE @datafilegrowthMB INT; DECLARE @logfilegrowthMB INT; DECLARE @sqlstring VARCHAR(8000); DECLARE @loop SMALLINT; SELECT @dbname = ‘tempdb’; SELECT @datasizeMB = 1024; SELECT…

Read More »

Posted in Server Setup Scritps

Config_Options

October 31, 2016
| No Comments
| Server Setup Scritps

— Focus on these settings: — backup compression default (should be 1 in most cases) — clr enabled (only enable if it is needed) — cost threshold for parallelism (depends on your workload) 50 is good — lightweight pooling (should be zero) — max degree of parallelism (depends on your workload) 4-8 — max server…

Read More »

Posted in Server Setup Scritps

Cycle_Error_Logs

October 31, 2016
| No Comments
| Server Setup Scritps

USE [msdb]; GO /****** Object: Job [(00:00) Maintenance – CycleErrorLogs] Script Date: 06/10/2014 11:19:43 ******/ BEGIN TRANSACTION; DECLARE @ReturnCode INT; SELECT @ReturnCode = 0; /****** Object: JobCategory [DBA_Maintenance] Script Date: 06/10/2014 11:19:43 ******/ IF NOT EXISTS ( SELECT name FROM msdb.dbo.syscategories WHERE name = N’DBA_Maintenance’ AND category_class = 1 ) BEGIN EXEC @ReturnCode = msdb.dbo.sp_add_category…

Read More »

Posted in Server Setup Scritps

Configure_MSDB

October 31, 2016
| No Comments
| Server Setup Scritps

USE [master]; GO — setup ALTER DATABASE [msdb] MODIFY FILE (NAME = N’MSDBData’, SIZE = 51200 KB, FILEGROWTH = 204800 KB ); GO ALTER DATABASE [msdb] MODIFY FILE (NAME = N’MSDBLog’, SIZE = 51200 KB, MAXSIZE = UNLIMITED, FILEGROWTH = 204800 KB ); GO

Read More »

Posted in Server Setup Scritps

Categories

Sidebar

  • November 2017 (1)
  • March 2017 (1)
  • October 2016 (13)
  • July 2016 (1)
  • May 2016 (1)
  • April 2016 (2)
  • March 2016 (1)
  • February 2016 (1)
  • November 2015 (2)
  • October 2015 (1)
  • September 2015 (1)
  • August 2015 (1)
  • July 2015 (7)
  • June 2015 (1)
  • May 2015 (6)
  • April 2015 (2)
  • March 2015 (2)
  • February 2015 (1)
  • January 2015 (1)
  • December 2014 (1)
  • November 2014 (1)
  • October 2014 (1)
  • September 2014 (1)
  • August 2014 (1)
  • July 2014 (1)
  • June 2014 (1)
  • May 2014 (1)
  • April 2014 (1)
  • March 2014 (1)
  • February 2014 (1)
  • January 2014 (1)
  • December 2013 (1)
  • November 2013 (1)
  • August 2013 (1)
  • July 2013 (1)
  • June 2013 (1)
  • April 2013 (1)
  • March 2013 (1)
  • February 2013 (1)
  • January 2013 (1)
  • December 2012 (1)
  • August 2012 (1)
  • June 2012 (1)
  • May 2012 (1)
  • April 2012 (1)
  • March 2012 (1)
  • February 2012 (1)
  • January 2012 (1)
  • October 2011 (1)
  • September 2011 (1)
  • August 2011 (1)
  • July 2011 (1)
  • June 2011 (1)
  • May 2011 (1)
  • April 2011 (1)
  • March 2011 (1)
  • January 2011 (1)
  • December 2010 (1)
  • September 2010 (1)
  • August 2010 (1)
  • July 2010 (1)
  • May 2010 (1)
  • March 2010 (1)
  • February 2010 (1)
  • January 2010 (1)
  • Server Setup Scritps
  • mssql
  • Scripts
  • MS Notification Services

Precious Lite 2022 | All Rights Reserved. Precious Lite theme by Flythemes