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 @StringTemplate VARCHAR(1000); | |
DECLARE @StringToExecute VARCHAR(1000); | |
DECLARE @Counter TINYINT = 1; | |
SET @StringTemplate = 'CREATE DATABASE [ConsumeMassQuantities##REPLACE##] | |
CONTAINMENT = NONE | |
ON PRIMARY | |
( NAME = N''ConsumeMassQuantities'', FILENAME = N''D:\MSSQL\Data\ConsumeMassQuantities##REPLACE##.mdf'' , SIZE = 8192KB , FILEGROWTH = 65536KB ) | |
LOG ON | |
( NAME = N''ConsumeMassQuantities_log'', FILENAME = N''D:\MSSQL\Data\ConsumeMassQuantities##REPLACE##_log.ldf'' , SIZE = 8192KB , FILEGROWTH = 65536KB )' |
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
USE StackOverflow; | |
GO | |
IF OBJECT_ID('dbo.usp_Q7521') IS NULL | |
EXEC ('CREATE PROCEDURE dbo.usp_Q7521 AS RETURN 0;') | |
GO | |
ALTER PROC dbo.usp_Q7521 @UserId INT AS | |
BEGIN | |
/* Source: http://data.stackexchange.com/stackoverflow/query/7521/how-unsung-am-i */ |
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
CREATE DATABASE [Collation_100_CI_AS_KS_WS_SC] | |
CONTAINMENT = NONE | |
ON PRIMARY | |
( NAME = N'Collation_100_CI_AS_KS_WS_SC', FILENAME = N'M:\MSSQL\Data\Collation_100_CI_AS_KS_WS_SC.mdf' , SIZE = 8192KB , FILEGROWTH = 65536KB ) | |
LOG ON | |
( NAME = N'Collation_100_CI_AS_KS_WS_SC_log', FILENAME = N'M:\MSSQL\Data\Collation_100_CI_AS_KS_WS_SC_log.ldf' , SIZE = 8192KB , FILEGROWTH = 65536KB ) | |
COLLATE Latin1_General_100_CS_AS_KS_WS_SC | |
GO | |
sp_BlitzIndex @DatabaseName = 'Collation_100_CI_AS_KS_WS_SC'; |
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
CREATE INDEX IX_UserId ON dbo.Badges(UserId); | |
GO | |
CREATE INDEX IX_PostId ON dbo.Comments(PostId); | |
GO | |
CREATE INDEX IX_UserId ON dbo.Comments(UserId); | |
GO | |
CREATE INDEX IX_PostId ON dbo.PostLinks(PostId); | |
GO | |
CREATE INDEX IX_RelatedPostId ON dbo.PostLinks(RelatedPostId); | |
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
/* | |
Wait stat categories from: https://docs.microsoft.com/en-us/sql/relational-databases/system-catalog-views/sys-query-store-wait-stats-transact-sql | |
Updated on: 2017/09/20 | |
*/ | |
IF OBJECT_ID('tempdb..##WaitCategories') IS NULL | |
BEGIN | |
/* We reuse this one by default rather than recreate it every time. */ | |
CREATE TABLE ##WaitCategories | |
( |
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
/* | |
This message gives me a clue about the database requirements: | |
10650 – Refresh of snapshot view(s) requires snapshot isolation to be enabled on the database. | |
So let's set that up: | |
*/ | |
CREATE VIEW dbo.Ocean WITH SNAPSHOT | |
AS |
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 @CurrentTraceFlag INT = 1 | |
/* Hard coding in a max number in case they get wise to this trick and start failing silently */ | |
WHILE @CurrentTraceFlag < 20000 | |
BEGIN | |
BEGIN TRY | |
DBCC TRACEON(@CurrentTraceFlag, -1); | |
DBCC TRACEOFF(@CurrentTraceFlag, -1); | |
END TRY | |
BEGIN CATCH | |
SELECT @CurrentTraceFlag, ERROR_NUMBER(), ERROR_MESSAGE(); |
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
/* | |
THIS IS A SPECTACULARLY BAD IDEA. | |
Never, ever, ever run this in production. | |
Don't even run it on a VM that you care about. | |
(I specifically build a throwaway VM just to run this.) | |
Get the latest version: | |
https://gist.github.com/BrentOzar/5d8e4e8cbc1d89d1021b6f889762d835 | |
*/ |
This file has been truncated, but you can view the full file.
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
Date,Source,Severity,Message | |
03/15/2018 21:01:51,spid120s,Unknown,[CFabricReplicaManager::GetServiceDescriptionFromFabric] EndGetServiceDescription for fabric service uri: fabric:/Worker.CL/ce39943cee8e/SQL.LogicalServer/ce39943cee8e completed with result: 80071bcd | |
03/15/2018 21:01:51,spid120s,Unknown,[CFabricReplicaManager::GetServiceDescriptionFromFabric] WaitForCallbackInvocation for fabric service uri: fabric:/Worker.CL/ce39943cee8e/SQL.LogicalServer/ce39943cee8e completed with result: 0 | |
03/15/2018 21:01:51,spid120s,Unknown,[CFabricReplicaManager::GetServiceDescriptionFromFabric] BeginGetServiceDescription for fabric service uri: fabric:/Worker.CL/ce39943cee8e/SQL.LogicalServer/ce39943cee8e completed with result: 0 | |
03/15/2018 21:01:51,spid120s,Unknown,[CFabricReplicaManager::GetServiceDescriptionFromFabric] GetFabricServiceNameInt for fabric service uri: fabric:/Worker.CL/ce39943cee8e/SQL.LogicalServer/ce39943cee8e completed with result: 0 | |
03/15/2018 21:01:51,spid120s,Unknown,[CFabricReplicaManager::GetSe |
This file has been truncated, but you can view the full file.
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
Date,Source,Severity,Message | |
03/16/2018 00:37:03,spid142s,Unknown,[CFabricReplicaManager::GetServiceDescriptionFromFabric] EndGetServiceDescription for fabric service uri: fabric:/Worker.CL/ce39943cee8e/SQL.LogicalServer/ce39943cee8e completed with result: 80071bcd | |
03/16/2018 00:37:03,spid142s,Unknown,[CFabricReplicaManager::GetServiceDescriptionFromFabric] WaitForCallbackInvocation for fabric service uri: fabric:/Worker.CL/ce39943cee8e/SQL.LogicalServer/ce39943cee8e completed with result: 0 | |
03/16/2018 00:37:03,spid142s,Unknown,[CFabricReplicaManager::GetServiceDescriptionFromFabric] BeginGetServiceDescription for fabric service uri: fabric:/Worker.CL/ce39943cee8e/SQL.LogicalServer/ce39943cee8e completed with result: 0 | |
03/16/2018 00:37:03,spid142s,Unknown,[CFabricReplicaManager::GetServiceDescriptionFromFabric] GetFabricServiceNameInt for fabric service uri: fabric:/Worker.CL/ce39943cee8e/SQL.LogicalServer/ce39943cee8e completed with result: 0 | |
03/16/2018 00:37:03,spid142s,Unknown,[CFabricReplicaManager::GetSe |
OlderNewer