This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| USE [msdb] | |
| GO | |
| /****** Object: Alert [AG Connection Timeout] Script Date: 1/13/2023 10:36:31 AM ******/ | |
| EXEC msdb.dbo.sp_add_alert @name=N'AG Connection Timeout', | |
| @message_id=35206, | |
| @severity=0, | |
| @enabled=1, | |
| @delay_between_responses=60, | |
| @include_event_description_in=1, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| SELECT DISTINCT | |
| RP.[name] | |
| , RP.[type_desc] AS role_type | |
| , PM.class_desc AS permission_type | |
| , PM.[permission_name] | |
| , pm.state_desc | |
| , CASE | |
| WHEN O1.type_desc IS NULL OR O1.type_desc = 'SYSTEM_TABLE' | |
| THEN PM.class_desc | |
| ELSE O1.[type_desc] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /*Note This script creates two stored procedures in the master database. The procedures are named sp_hexadecimal and sp_help_revlogin. */ | |
| -- Create stored procedure sp_hexadecimal | |
| USE master | |
| GO | |
| IF OBJECT_ID ('sp_hexadecimal') IS NOT NULL | |
| DROP PROCEDURE sp_hexadecimal | |
| GO | |
| CREATE PROCEDURE sp_hexadecimal | |
| @binvalue varbinary(256), | |
| @hexvalue varchar (514) OUTPUT |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $scanPSTExe = "C:\Program Files\Microsoft Office\root\Office16\SCANPST.EXE" | |
| $SourceDir = "E:\Outlook\test" | |
| $BackupDir = "F:\Backups\Outlook\test" | |
| $MaxIterations = 10 | |
| $PSTs = Get-ChildItem -Path (Join-Path $SourceDir "\*") -Include *.pst,*.ost -File | |
| $PSTs | ForEach-Object { | |
| $NumIteration = 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| DECLARE @old_email_address nvarchar(128) = N'[email protected]'; | |
| DECLARE @new_email_address nvarchar(128) = N'[email protected]'; | |
| DECLARE @old_replyto_address nvarchar(128) = N'[email protected]'; | |
| DECLARE @new_replyto_address nvarchar(128) = N'[email protected]'; | |
| DECLARE @test_email_address nvarchar(128) = N'[email protected]'; | |
| USE msdb; | |
| SET NOCOUNT ON; | |
| IF OBJECT_ID('tempdb..#tmp_account') IS NOT NULL |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| SELECT | |
| FLOOR(transferred_size_bytes * 1. / NULLIF(database_size_bytes, 0) * 100) AS Perc | |
| , transfer_rate_bytes_per_second / 1024 / 1024. AS MBSec | |
| , internal_state_desc | |
| , start_time_utc, estimate_time_complete_utc | |
| , FLOOR(transferred_size_bytes / 1024. / 1024. / 1024.) AS transferred_size_GB | |
| , FLOOR(database_size_bytes / 1024. / 1024. / 1024.) AS database_size_bytes_GB | |
| , * | |
| FROM sys.dm_hadr_physical_seeding_stats |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| WITH cte AS | |
| ( | |
| SELECT | |
| CASE | |
| WHEN PATINDEX('SQL Server (%', servicename) > 0 | |
| THEN 'Engine' | |
| WHEN PATINDEX('SQL Server Agent (%', servicename) > 0 | |
| THEN 'Agent' | |
| WHEN PATINDEX('SQL Full-text Filter Daemon Launcher (%', servicename) > 0 | |
| THEN 'FullText' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| WITH cte AS | |
| ( | |
| SELECT | |
| RH.destination_database_name, RH.restore_type | |
| , ROW_NUMBER() OVER (PARTITION BY RH.destination_database_name, RH.restore_type ORDER BY RH.restore_history_id DESC) AS rn | |
| , RH.restore_date, BS.backup_start_date, BS.backup_finish_date | |
| , CASE WHEN CONVERT(varchar, DATEDIFF(ms, backup_start_date, backup_finish_date) / 1000 / 86400) > 0 THEN CONVERT(varchar, DATEDIFF(ms, backup_start_date, backup_finish_date) / 1000 / 86400) + ' day(s) ' ELSE '' END + CONVERT(varchar, DATEADD(ms, DATEDIFF(ms, backup_start_date, backup_finish_date), 0), 114) AS elapsed_time | |
| , FORMAT(BS.backup_size / 1073741824., 'N2') AS backup_size_gb | |
| , FORMAT(BS.compressed_backup_size / 1073741824., 'N2') AS compressed_backup_size_gb | |
| FROM msdb.dbo.restorehistory AS RH |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| SELECT | |
| JO.[name] AS job_name, JO.[enabled] | |
| , JS.step_id, JS.step_name, JS.subsystem, JS.command | |
| FROM msdb.dbo.sysjobs AS JO | |
| JOIN msdb.dbo.sysjobsteps as JS | |
| ON JO.job_id = JS.job_id | |
| WHERE JS.command like N'%something%' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| EXEC sp_msforeachdb 'USE [?]; | |
| SELECT | |
| DB_NAME() | |
| , S.[object_id], S.[stats_id] | |
| , FORMATMESSAGE( | |
| N''[%s].[%s]'' | |
| , OBJECT_SCHEMA_NAME(S.[object_id]) | |
| , OBJECT_NAME(S.[object_id]) | |
| )AS object_full_name | |
| , QUOTENAME(S.[name]) AS stat_name |
NewerOlder