🕵️♂️
This file contains 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 @MaxEndTime datetime = DATEADD(HOUR, 2, GETDATE()) | |
DECLARE @TimeLimitSeconds int; | |
SET @TimeLimitSeconds = DATEDIFF(second, GETDATE(), @MaxEndTime) | |
EXEC dbo.DatabaseIntegrityCheck | |
@Databases = 'ALL_DATABASES', | |
@DatabaseOrder = 'DATABASE_LAST_GOOD_CHECK_ASC', | |
@CheckCommands = 'CHECKALLOC,CHECKCATALOG', | |
--@PhysicalOnly = 'Y', |
This file contains 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 @EndTime datetime = DATEADD(hour, 2, GETDATE()) -- Adjust the time limit as needed | |
DECLARE @OlaHallengrenDBName sysname = DB_NAME() -- This script must run within the context of the database where Ola's maintenance solution was installed | |
DECLARE @DBName sysname, @ObjNameFull nvarchar(4000), @ObjNameLean sysname, @SchName sysname | |
DECLARE @CheckTime datetime, @LastCheckDate datetime, @ObjType sysname | |
IF OBJECT_ID('tempdb..#Objects') IS NOT NULL DROP TABLE #Objects; | |
CREATE TABLE #Objects | |
( | |
DBName sysname, |
This file contains 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
/* | |
https://learn.microsoft.com/en-us/sql/t-sql/statements/alter-table-transact-sql?view=sql-server-ver16#switch--partition-source_partition_number_expression--to--schema_name--target_table--partition-target_partition_number_expression- | |
*/ | |
SET NOCOUNT ON; | |
GO | |
CREATE PARTITION FUNCTION PF1 (int) AS RANGE RIGHT FOR VALUES (0, 100) | |
CREATE PARTITION SCHEME PS1 AS PARTITION PF1 ALL TO ([PRIMARY]); | |
GO | |
CREATE PARTITION FUNCTION PF2 (int) AS RANGE RIGHT FOR VALUES (0, 100, 200) | |
CREATE PARTITION SCHEME PS2 AS PARTITION PF2 ALL TO ([PRIMARY]); |
This file contains 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
DROP TABLE IF EXISTS [dbo].[TestTable2]; | |
DROP TABLE IF EXISTS [dbo].[TestTable1]; | |
DROP TABLE IF EXISTS dbo.TestEdgeTable; | |
DROP TABLE IF EXISTS dbo.TestNodeTable1; | |
DROP TABLE IF EXISTS dbo.TestNodeTable2; | |
DROP TABLE IF EXISTS dbo.TestNodeTable3; | |
GO | |
IF SCHEMA_ID('EitanTest') IS NOT NULL DROP SCHEMA EitanTest; | |
GO | |
CREATE SCHEMA EitanTest AUTHORIZATION dbo; |
This file contains 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
# SQL Database Project Build Configuration | |
trigger: | |
- master | |
pool: | |
vmImage: 'VS2017-Win2016' | |
variables: | |
solution: '**/*.sln' |
This file contains 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
-- Run this in the right SQL Sentry database | |
--USE [SentryOne]; | |
--USE [SQLSentry]; | |
GO | |
IF OBJECT_ID('[dbo].[heartbeat_log]') IS NULL | |
BEGIN | |
CREATE TABLE [dbo].[heartbeat_log]( | |
[servername] [nvarchar](300) CONSTRAINT PK_Heartbeat_Log PRIMARY KEY CLUSTERED WITH(IGNORE_DUP_KEY=ON,DATA_COMPRESSION=PAGE), | |
[heartbeatdate] [datetime] NULL, | |
[ActualHeartbeatDate] [datetime] NULL |
This file contains 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
/* | |
Check for low PAGE compression success rates | |
============================================ | |
Author: Eitan Blumin | |
Date: 2022-01-13 | |
Based on blog post by Paul Randal: | |
https://www.sqlskills.com/blogs/paul/the-curious-case-of-tracking-page-compression-success-rates/ | |
*/ | |
DECLARE | |
/* threshold parameters: */ |
This file contains 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
SET SHOWPLAN_XML ON; | |
GO | |
/* TODO: Add your test query here to get its estimated plan WITHOUT the hypothetical indexes */ | |
GO | |
SET SHOWPLAN_XML OFF; | |
GO |
This file contains 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
# Copyright 2021 Eitan Blumin <@EitanBlumin, https://www.eitanblumin.com> | |
# while at Madeira Data Solutions <https://www.madeiradata.com> | |
# | |
# Licensed under the MIT License (the "License"); | |
# | |
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | |
# | |
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | |
# | |
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR CO |
This file contains 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 | |
@TopPerDB int = 50, | |
@MinimumRowCount int = 1000, | |
@MinimumUnusedSizeMB int = 1024, | |
@MinimumUnusedSpacePct int = 40, | |
@RebuildIndexOptions varchar(max) = 'ONLINE = ON, SORT_IN_TEMPDB = ON, MAXDOP = 1' -- , RESUMABLE = ON -- adjust as needed | |
SET NOCOUNT, ARITHABORT, XACT_ABORT ON; | |
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; | |
DECLARE @command NVARCHAR(MAX); |
NewerOlder