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 dbo.sp_GetFullName 'TFly37' |
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
CREATE PROCEDURE dbo.sp_GetFullName | |
@ParmUserName varchar(100) | |
AS | |
BEGIN | |
DECLARE @FullQuery varchar(1000) | |
SET @FullQuery = 'SELECT FullName FROM dbo.RegisteredUser WHERE UserName = ''' + @ParmUserName + '''' | |
EXEC(@FullQuery); | |
END |
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 Sandbox; | |
GO | |
DROP TABLE IF EXISTS dbo.RegisteredUser | |
CREATE TABLE dbo.RegisteredUser | |
( | |
Id INT IDENTITY(1,1), | |
FullName varchar(100), | |
UserName varchar(40), | |
HashedPassword varchar(66), | |
JoinDate datetime2 |
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
-- Test data taken from my favorite green coffee seller's website, Sweet Maria's https://www.sweetmarias.com/category/green-coffee | |
--DROP TABLE IF EXISTS dbo.CoffeeInventory | |
DROP TABLE dbo.CoffeeInventory | |
CREATE TABLE dbo.CoffeeInventory | |
( | |
ID int IDENTITY(1,1), | |
Name VARCHAR(100), | |
Price DECIMAL(4,2), | |
Description VARCHAR(500), |
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
-- From https://github.com/bertwagner/SQLServer/blob/master/Non-SARGable%20Execution%20Plans.sql | |
-- This script will check the execution plan cache for any queries that are non-SARGable. | |
-- It does this by finding table and index scans that contain a scalar operators | |
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED | |
DECLARE @dbname SYSNAME | |
SET @dbname = QUOTENAME(DB_NAME()); | |
WITH XMLNAMESPACES (DEFAULT 'http://schemas.microsoft.com/sqlserver/2004/07/showplan') |
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 Sandbox | |
GO | |
-- Test data taken from my favorite green coffee seller's website, Sweet Maria's https://www.sweetmarias.com/category/green-coffee | |
DROP TABLE IF EXISTS dbo.CoffeeInventory | |
CREATE TABLE dbo.CoffeeInventory | |
( | |
ID int IDENTITY(1,1), | |
Name VARCHAR(100), | |
Price DECIMAL(4,2), | |
Description VARCHAR(500), |
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
-- Test data taken from my favorite green coffee seller's website, Sweet Maria's https://www.sweetmarias.com/category/green-coffee | |
DROP TABLE IF EXISTS dbo.CoffeeInventory | |
CREATE TABLE dbo.CoffeeInventory | |
( | |
ID int IDENTITY(1,1), | |
Name VARCHAR(100), | |
Price VARCHAR(5),--DECIMAL(4,2), | |
Description VARCHAR(500), | |
CreateDate DATETIME2 DEFAULT GETDATE() | |
) |
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
-- Drop and create our temporal and historical tables | |
IF OBJECT_ID('dbo.CarInventory', 'U') IS NOT NULL | |
BEGIN | |
-- When deleting a temporal table, we need to first turn versioning off | |
ALTER TABLE dbo.CarInventory SET ( SYSTEM_VERSIONING = OFF ) | |
DROP TABLE dbo.CarInventory | |
DROP TABLE dbo.CarInventoryHistory | |
END; | |
CREATE TABLE CarInventory | |
( |
This file has been truncated, but you can view the full file.
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
using Newtonsoft.Json; | |
using System; | |
using System.Collections.Generic; | |
using System.Data.SqlClient; | |
using System.Diagnostics; | |
using System.IO; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
using System.Xml.Serialization; |
This file has been truncated, but you can view the full file.
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
-- Create our test data: A table of a car dealer's inventory of cars | |
-- car data source: https://github.com/arthurkao/vehicle-make-model-data | |
DROP TABLE IF EXISTS dbo.AllCarsInOneRow | |
CREATE TABLE dbo.AllCarsInOneRow | |
( | |
Id INT IDENTITY(1,1), | |
CarDetails NVARCHAR(MAX) | |
); | |
DROP TABLE IF EXISTS dbo.XmlVsJson | |
CREATE TABLE dbo.XmlVsJson |