├── .gitignore ├── Companion Materials (Books) ├── Pro SQL Server Internals 1st Edition │ ├── 32.Chapter 32 (Hekaton Internals) │ │ └── SQLQuery1.sql │ ├── 14.Chapter 14 (CLR Types) │ │ └── 14.Chapter 14 (CLR Types) (SQL Server 2005).ssmssqlproj │ ├── 04.Chapter 04 (Special Features) │ │ └── 04.Chapter 04 (Special Features) (SQL Server 2005).ssmssqlproj │ ├── 29.Chapter 29 (Transaction Log Internals) │ │ └── 29.Chapter 29 (Transaction Log Internals).ssmssqlproj │ ├── 27.Chapter 27 (System Troubleshooting) │ │ ├── 06.Enable Remote DAC.sql │ │ └── 04.Buffer Pool Usage.sql │ ├── 00.Init │ │ ├── 00.Init.ssmssqlproj │ │ └── 00.Init (SQL Server 2014).ssmssqlproj │ ├── 19.Chapter 19 (Deadlocks) │ │ ├── 03.2.Multiple Updates.sql │ │ └── 02.2.Key Lookup Deadlock.sql │ ├── 18.Chapter 18 (Troubleshooting Blocking Issues) │ │ └── 03.Set Blocked Process Threshold.sql │ ├── 07.Chapter 07 (Constraints) │ │ └── 07.Chapter 07 (Constraints).ssmssqlproj │ ├── 05.Chapter 05 (Index Fragmentation) │ │ └── 05.Chapter 05 (Index Fragmentation).ssmssqlproj │ ├── 08.Chapter 08 (Triggers) │ │ ├── 08.Chapter 08 (Triggers) (SQL Server 2005).ssmssqlproj │ │ └── 08.Chapter 08 (Triggers).ssmssqlproj │ ├── 16.Chapter 16 (System Design Considerations) │ │ └── 16.Chapter 16 (System Design Considerations).ssmssqlproj │ ├── 01.Chapter 01 (Data Storage Internals) │ │ └── 01.Check Instant File Initialization.sql │ ├── 23.Chapter 23 (Schema Locks) │ │ ├── 01.2.Schema Locks.sql │ │ ├── 02.2.Lock Compatibility.sql │ │ └── 01.3.Schema Locks.sql │ ├── 11.Chapter 11 (XML) │ │ └── 11.Chapter 11 (XML).ssmssqlproj │ └── 10.Chapter 10 (Functions) │ │ └── 10.Chapter 10 (Functions).ssmssqlproj ├── Expert SQL Server Transactions and Locking │ ├── 07.Chapter 07 (Lock Escalation) │ │ ├── SQLQuery1.sql │ │ ├── 01.2 Lock Escalation and Concurrency.sql │ │ └── 02.Multiple Statements.sql │ ├── 04.Chapter 04 (Blocking In The System) │ │ ├── SQLQuery1.sql │ │ ├── 06.Capturing Blocking Info with Event Notifications.sql │ │ ├── 01.2.Creating Blocking.sql │ │ ├── 03.Set Blocked Process Threshold.sql │ │ └── 01.1.Creating Blocking.sql │ ├── 00.Init │ │ └── 00.Init.ssmssqlproj │ ├── 14.Chapter 14 (Locking and Columnstore Indexes) │ │ ├── 02.2.Insert.sql │ │ ├── 03.2.Update.sql │ │ ├── 04.2.Delete.sql │ │ ├── 05.Create NCI.sql │ │ └── 06.Nonclustered Columnstore Indexes.sql │ ├── 08.Chapter 08 (Schema and Low Priority Locks) │ │ ├── 01.2.Schema Locks.sql │ │ ├── 01.3.Schema Locks.sql │ │ └── 02.2.Lock Compatibility.sql │ ├── 12.Chapter 12 (Troubleshooting Concurrency Issues) │ │ ├── 06.3.Blocking Chains.sql │ │ ├── 06.4.Blocking Chains.sql │ │ ├── 08.2.Readable Secondaries.sql │ │ ├── 03.Wait Type Map.sql │ │ └── 06.2.Blocking Chains.sql │ ├── 06.Chapter 06 (Optimistic Isolation Levels) │ │ └── 03.2.Error 3960.sql │ ├── 10.Chapter 10 (Application Locks) │ │ ├── 02.2.Application Locks.sql │ │ └── 04.2.Object Access.sql │ ├── 05.Chapter 05 (Deadlocks) │ │ ├── 03.2.Multiple Updates.sql │ │ ├── 02.2.Key Lookup Deadlock.sql │ │ ├── 01.2.Non-optimized Queries Deadlock.sql │ │ └── 01.1.Non-optimized Queries Deadlock.sql │ ├── 13.Chapter 13 (In-Memory OLTP Concurrency Model) │ │ ├── 06.2.PK Violation.sql │ │ ├── 03.2.Serializable.sql │ │ ├── 02.2.Repeatable Read.sql │ │ ├── 04.2.Snapshot.sql │ │ ├── 06.1.PK Violation.sql │ │ ├── 07.2.Ref Integrity.sql │ │ └── 05.2.Write-Write Conflict.sql │ ├── 09.Chapter 09 (Lock Partitioning) │ │ └── 02.2.Lock Partitioning Deadlock.sql │ └── 03.Chapter 03 (Lock Types) │ │ └── 03.2.(S) Locks.sql ├── Applications (Net Code) │ ├── Ad-Hoc Demo │ │ ├── bin │ │ │ └── Debug │ │ │ │ ├── AdHocDemo.exe │ │ │ │ ├── AdHocDemo.pdb │ │ │ │ ├── AdHocDemo.vshost.exe │ │ │ │ ├── LogRequestsGenerator.exe │ │ │ │ ├── LogRequestsGenerator.pdb │ │ │ │ ├── AboutSqlServer.Com.Classes.dll │ │ │ │ ├── AboutSqlServer.Com.Classes.pdb │ │ │ │ ├── LogRequestsGenerator.vshost.exe │ │ │ │ ├── LogRequestsGenerator.exe.config │ │ │ │ ├── LogRequestsGenerator.vshost.exe.config │ │ │ │ ├── AdHocDemo.vshost.exe.config │ │ │ │ └── AdHocDemo.exe.config │ │ ├── Properties │ │ │ ├── Settings.settings │ │ │ └── Settings.Designer.cs │ │ ├── App.config │ │ ├── Program.cs │ │ └── AdHocDemoStatThread.cs │ ├── CLR │ │ ├── SQL Server 2005 │ │ │ ├── CLRTest │ │ │ │ ├── CLRTest.sqlproj.user │ │ │ │ └── bin │ │ │ │ │ └── Debug │ │ │ │ │ ├── CLRTest.dll │ │ │ │ │ ├── CLRTest.pdb │ │ │ │ │ └── CLRTest.dacpac │ │ │ └── CLRTest.sln │ │ ├── SQL Server 2012-2016 │ │ │ ├── CLRTest │ │ │ │ ├── CLRTest.sqlproj.user │ │ │ │ └── bin │ │ │ │ │ └── Debug │ │ │ │ │ ├── CLRTest.dll │ │ │ │ │ ├── CLRTest.pdb │ │ │ │ │ └── CLRTest.dacpac │ │ │ └── CLRTest.sln │ │ └── SQL Server 2008-2008R2 │ │ │ ├── CLRTest │ │ │ ├── CLRTest.sqlproj.user │ │ │ └── bin │ │ │ │ └── Debug │ │ │ │ ├── CLRTest.dll │ │ │ │ ├── CLRTest.pdb │ │ │ │ └── CLRTest.dacpac │ │ │ └── CLRTest.sln │ ├── In-Memory OLTP │ │ ├── SessionStoreDemo │ │ │ ├── bin │ │ │ │ └── Debug │ │ │ │ │ ├── SessionStoreDemo.exe │ │ │ │ │ ├── SessionStoreDemo.pdb │ │ │ │ │ ├── SessionStoreDemo.vshost.exe │ │ │ │ │ ├── AboutSqlServer.Com.Classes.dll │ │ │ │ │ ├── AboutSqlServer.Com.Classes.pdb │ │ │ │ │ ├── SessionStoreDemo.vshost.exe.manifest │ │ │ │ │ ├── SessionStoreDemo.exe.config │ │ │ │ │ └── SessionStoreDemo.vshost.exe.config │ │ │ ├── Properties │ │ │ │ ├── Settings.settings │ │ │ │ └── Settings.Designer.cs │ │ │ └── App.config │ │ ├── LogRequestsGenerator │ │ │ ├── bin │ │ │ │ └── Debug │ │ │ │ │ ├── LogRequestsGenerator.exe │ │ │ │ │ ├── LogRequestsGenerator.pdb │ │ │ │ │ ├── AboutSqlServer.Com.Classes.dll │ │ │ │ │ ├── AboutSqlServer.Com.Classes.pdb │ │ │ │ │ ├── LogRequestsGenerator.vshost.exe │ │ │ │ │ ├── LogRequestsGenerator.exe.config │ │ │ │ │ └── LogRequestsGenerator.vshost.exe.config │ │ │ ├── Properties │ │ │ │ ├── Settings.settings │ │ │ │ └── Settings.Designer.cs │ │ │ └── App.config │ │ └── AboutSqlServer.Com.Classes │ │ │ └── bin │ │ │ └── Debug │ │ │ ├── AboutSqlServer.Com.Classes.dll │ │ │ └── AboutSqlServer.Com.Classes.pdb │ ├── SaveRecordSet │ │ ├── SaveRecordSetApp │ │ │ ├── bin-.Net 3.5 │ │ │ │ └── Debug │ │ │ │ │ ├── SaveRecordSetApp.exe │ │ │ │ │ ├── SaveRecordSetApp.pdb │ │ │ │ │ ├── SaveRecordSetApp.vshost.exe │ │ │ │ │ ├── SaveRecordSetApp.exe.config │ │ │ │ │ ├── SaveRecordSetApp.vshost.exe.config │ │ │ │ │ └── SaveRecordSetApp.vshost.exe.manifest │ │ │ ├── bin-.Net 4.5 │ │ │ │ └── Debug │ │ │ │ │ ├── SaveRecordSetApp.exe │ │ │ │ │ ├── SaveRecordSetApp.pdb │ │ │ │ │ ├── SaveRecordSetApp.vshost.exe │ │ │ │ │ ├── SaveRecordSetApp.exe.config │ │ │ │ │ ├── SaveRecordSetApp.vshost.exe.manifest │ │ │ │ │ └── SaveRecordSetApp.vshost.exe.config │ │ │ ├── Properties │ │ │ │ ├── Settings.settings │ │ │ │ └── Settings.Designer.cs │ │ │ └── app.config │ │ └── SaveRecordSet.sln │ └── README.txt ├── SQL Server Advanced Troubleshooting And Performance Tuning │ ├── 08.Locking, Blocking and Concurrency │ │ ├── 03.1.Lock Escalation (Session 1).sql │ │ ├── 01.2.Blocking (Session 2).sql │ │ ├── 03.2.Lock Escalation (Session 2).sql │ │ └── 02.2.Deadlocks (Session 2).sql │ ├── README.txt │ ├── 00.Create Database │ │ └── 00.Create Database.ssmssqlproj │ ├── 07.Memory Issues │ │ └── 07.Memory Issues.ssmssqlproj │ ├── 11.Transaction Log │ │ └── 11.Transaction Log.ssmssqlproj │ ├── 10.Latches │ │ └── 10.Latches.ssmssqlproj │ ├── 09.TempDB Usage and Performance │ │ └── 09.TempDB Usage and Performance.ssmssqlproj │ └── 06.CPU Load │ │ └── 06.CPU Load.ssmssqlproj ├── Expert SQL Server In-Memory OLTP (1st Edition) │ ├── 00.Init │ │ └── 00.Init.ssmssqlproj │ ├── 08.Chapter 08 (Data Storage, Logging and Recovery) │ │ └── 08.Chapter 08 (Data Storage, Logging and Recovery).ssmssqlproj │ ├── 06.Chapter 06 (In-Memory OLTP Programmability) │ │ └── 02.2.Atomic Blocks.sql │ ├── 07.Chapter 07 (In-Memory OLTP Concurrency Model) │ │ ├── 06.2.PK Violation.sql │ │ ├── 03.2.Serializable.sql │ │ ├── 02.2.Repeatable Read.sql │ │ ├── 04.2.Snapshot.sql │ │ ├── 06.1.PK Violation.sql │ │ └── 05.2.Write-Write Conflict.sql │ ├── 11.Chapter 11 (Untilizing In-Memory OLTP) │ │ ├── 03.2.Uniqueness Support.sql │ │ └── 08.3.TV Performance DW - Update.sql │ ├── 14.Appendix C (Analyzing the States of CFPs) │ │ └── 14.Appendix C (Analyzing the States of CFPs).ssmssqlproj │ ├── 02.Chapter 02 (In-Memory OLTP Objects) │ │ └── 02.Chapter 02 (In-Memory OLTP Objects).ssmssqlproj │ ├── 04.Chapter 04 (Hash Indexes) │ │ └── 04.Statistics.sql │ ├── 09.Chapter 09 (Garbage Collection) │ │ └── 09.Chapter 09 (Garbage Collection).ssmssqlproj │ └── 05.Chapter 05 (Nonclustered Indexes) │ │ └── 05.Chapter 05 (Nonclustered Indexes).ssmssqlproj ├── Expert SQL Server In-Memory OLTP (2nd Edition) │ ├── 00.Init │ │ └── 00.Init.ssmssqlproj │ ├── 17.Appendix D (In-Memory OLTP Migration Tools) │ │ └── 17.Appendix D (In-Memory OLTP Migration Tools).ssmssqlproj │ ├── 08.Chapter 08 (Transaction Processing) │ │ ├── 07.2.Ref Integrity.sql │ │ ├── 06.2.PK Violation.sql │ │ ├── 03.2.Serializable.sql │ │ ├── 02.2.Repeatable Read.sql │ │ ├── 04.2.Snapshot.sql │ │ ├── 06.1.PK Violation.sql │ │ ├── 05.2.Write-Write Conflict.sql │ │ └── 01.Table Creation.sql │ ├── 09.Chapter 09 (In-Memory OLTP Programmability) │ │ └── 02.2.Atomic Blocks.sql │ ├── 13.Chapter 13 (Untilizing In-Memory OLTP) │ │ ├── 03.2.Uniqueness Support.sql │ │ └── 03.2.Referential Integrity.sql │ ├── 16.Appendix C (Analyzing the States of CFPs) │ │ └── 16.Appendix C (Analyzing the States of CFPs).ssmssqlproj │ ├── 06.Chapter 06 (Memory Consumers, Off-Row Storage) │ │ └── SQLQuery1.sql │ └── 02.Chapter 02 (In-Memory OLTP Objects) │ │ └── 02.Chapter 02 (In-Memory OLTP Objects).ssmssqlproj └── Pro SQL Server Internals 2nd Edition │ ├── 00.Init │ ├── 00.Init.ssmssqlproj │ └── 00.Init (SQL Server 2014-2016).ssmssqlproj │ ├── 15.Chapter 15 (CLR Types) │ └── 15.Chapter 15 (CLR Types) (SQL Server 2005).ssmssqlproj │ ├── 30.Chapter 30 (Transaction Log Internals) │ └── 30.Chapter 30 (Transaction Log Internals).ssmssqlproj │ ├── 34.Chapter 34 (Columnstore Indexes) │ └── 34.Chapter 34 (Columnstore Indexes) (SQL Server 2012).ssmssqlproj │ ├── 28.Chapter 28 (System Troubleshooting) │ ├── 06.Enable Remote DAC.sql │ └── 04.Buffer Pool Usage.sql │ ├── 19.Chapter 19 (Deadlocks) │ ├── 03.2.Multiple Updates.sql │ └── 02.2.Key Lookup Deadlock.sql │ ├── 18.Chapter 18 (Troubleshooting Blocking Issues) │ └── 03.Set Blocked Process Threshold.sql │ ├── 08.Chapter 08 (Constraints) │ └── 08.Chapter 08 (Constraints).ssmssqlproj │ ├── 06.Chapter 06 (Index Fragmentation) │ └── 06.Chapter 06 (Index Fragmentation).ssmssqlproj │ ├── 04.Chapter 04 (Special Features) │ └── 04.Chapter 04 (Special Features) (SQL Server 2005).ssmssqlproj │ ├── 99.Chapter 99 (System Design Considerations) │ └── 99.Chapter 99 (System Design Considerations).ssmssqlproj │ ├── 01.Chapter 01 (Data Storage Internals) │ └── 01.Check Instant File Initialization.sql │ ├── 23.Chapter 23 (Schema Locks) │ ├── 01.2.Schema Locks.sql │ ├── 02.2.Lock Compatibility.sql │ └── 01.3.Schema Locks.sql │ └── 21.Chapter 21 (Optimistic Isolation Levels) │ └── 03.2.Error 3960.sql ├── Presentations └── Intro Into Index Analysis │ ├── Intro Into Index Analysis (2022).pdf │ └── SQL │ ├── 90.Redundant Indexes.sql │ ├── 92.Index Usage from Plan Cache.sql │ ├── 91.Table Info.sql │ ├── IndexAnalysis.ssmssln │ └── 03.NCI Usage.sql ├── README.md └── Blocking Monitoring Framework ├── Setup ├── 08.Set Version.sql ├── 05.1.Security (Trustworthy).sql └── 06.Enabling Activation.sql ├── Testing ├── 01.2.Blocking Testing (Session 2).sql ├── 02.2.Deadlock Testing (Session 2).sql ├── 02.1.Deadlock Testing (Session 1).sql └── 01.1.Blocking Testing (Session 1).sql ├── Analysis └── Analysis.ssmssqlproj └── BMFramework.ssmssln /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | -------------------------------------------------------------------------------- /Companion Materials (Books)/Pro SQL Server Internals 1st Edition/32.Chapter 32 (Hekaton Internals)/SQLQuery1.sql: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Companion Materials (Books)/Expert SQL Server Transactions and Locking/07.Chapter 07 (Lock Escalation)/SQLQuery1.sql: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Companion Materials (Books)/Expert SQL Server Transactions and Locking/04.Chapter 04 (Blocking In The System)/SQLQuery1.sql: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Presentations/Intro Into Index Analysis/Intro Into Index Analysis (2022).pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aboutsqlserver/code/HEAD/Presentations/Intro Into Index Analysis/Intro Into Index Analysis (2022).pdf -------------------------------------------------------------------------------- /Companion Materials (Books)/Applications (Net Code)/Ad-Hoc Demo/bin/Debug/AdHocDemo.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aboutsqlserver/code/HEAD/Companion Materials (Books)/Applications (Net Code)/Ad-Hoc Demo/bin/Debug/AdHocDemo.exe -------------------------------------------------------------------------------- /Companion Materials (Books)/Applications (Net Code)/Ad-Hoc Demo/bin/Debug/AdHocDemo.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aboutsqlserver/code/HEAD/Companion Materials (Books)/Applications (Net Code)/Ad-Hoc Demo/bin/Debug/AdHocDemo.pdb -------------------------------------------------------------------------------- /Companion Materials (Books)/Applications (Net Code)/Ad-Hoc Demo/bin/Debug/AdHocDemo.vshost.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aboutsqlserver/code/HEAD/Companion Materials (Books)/Applications (Net Code)/Ad-Hoc Demo/bin/Debug/AdHocDemo.vshost.exe -------------------------------------------------------------------------------- /Companion Materials (Books)/Applications (Net Code)/CLR/SQL Server 2005/CLRTest/CLRTest.sqlproj.user: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /Companion Materials (Books)/Applications (Net Code)/Ad-Hoc Demo/bin/Debug/LogRequestsGenerator.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aboutsqlserver/code/HEAD/Companion Materials (Books)/Applications (Net Code)/Ad-Hoc Demo/bin/Debug/LogRequestsGenerator.exe -------------------------------------------------------------------------------- /Companion Materials (Books)/Applications (Net Code)/Ad-Hoc Demo/bin/Debug/LogRequestsGenerator.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aboutsqlserver/code/HEAD/Companion Materials (Books)/Applications (Net Code)/Ad-Hoc Demo/bin/Debug/LogRequestsGenerator.pdb -------------------------------------------------------------------------------- /Companion Materials (Books)/Applications (Net Code)/CLR/SQL Server 2012-2016/CLRTest/CLRTest.sqlproj.user: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /Companion Materials (Books)/Applications (Net Code)/CLR/SQL Server 2005/CLRTest/bin/Debug/CLRTest.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aboutsqlserver/code/HEAD/Companion Materials (Books)/Applications (Net Code)/CLR/SQL Server 2005/CLRTest/bin/Debug/CLRTest.dll -------------------------------------------------------------------------------- /Companion Materials (Books)/Applications (Net Code)/CLR/SQL Server 2005/CLRTest/bin/Debug/CLRTest.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aboutsqlserver/code/HEAD/Companion Materials (Books)/Applications (Net Code)/CLR/SQL Server 2005/CLRTest/bin/Debug/CLRTest.pdb -------------------------------------------------------------------------------- /Companion Materials (Books)/Applications (Net Code)/CLR/SQL Server 2008-2008R2/CLRTest/CLRTest.sqlproj.user: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /Companion Materials (Books)/Applications (Net Code)/Ad-Hoc Demo/bin/Debug/AboutSqlServer.Com.Classes.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aboutsqlserver/code/HEAD/Companion Materials (Books)/Applications (Net Code)/Ad-Hoc Demo/bin/Debug/AboutSqlServer.Com.Classes.dll -------------------------------------------------------------------------------- /Companion Materials (Books)/Applications (Net Code)/Ad-Hoc Demo/bin/Debug/AboutSqlServer.Com.Classes.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aboutsqlserver/code/HEAD/Companion Materials (Books)/Applications (Net Code)/Ad-Hoc Demo/bin/Debug/AboutSqlServer.Com.Classes.pdb -------------------------------------------------------------------------------- /Companion Materials (Books)/Applications (Net Code)/CLR/SQL Server 2005/CLRTest/bin/Debug/CLRTest.dacpac: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aboutsqlserver/code/HEAD/Companion Materials (Books)/Applications (Net Code)/CLR/SQL Server 2005/CLRTest/bin/Debug/CLRTest.dacpac -------------------------------------------------------------------------------- /Companion Materials (Books)/Applications (Net Code)/Ad-Hoc Demo/bin/Debug/LogRequestsGenerator.vshost.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aboutsqlserver/code/HEAD/Companion Materials (Books)/Applications (Net Code)/Ad-Hoc Demo/bin/Debug/LogRequestsGenerator.vshost.exe -------------------------------------------------------------------------------- /Companion Materials (Books)/Applications (Net Code)/CLR/SQL Server 2012-2016/CLRTest/bin/Debug/CLRTest.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aboutsqlserver/code/HEAD/Companion Materials (Books)/Applications (Net Code)/CLR/SQL Server 2012-2016/CLRTest/bin/Debug/CLRTest.dll -------------------------------------------------------------------------------- /Companion Materials (Books)/Applications (Net Code)/CLR/SQL Server 2012-2016/CLRTest/bin/Debug/CLRTest.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aboutsqlserver/code/HEAD/Companion Materials (Books)/Applications (Net Code)/CLR/SQL Server 2012-2016/CLRTest/bin/Debug/CLRTest.pdb -------------------------------------------------------------------------------- /Companion Materials (Books)/Applications (Net Code)/CLR/SQL Server 2008-2008R2/CLRTest/bin/Debug/CLRTest.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aboutsqlserver/code/HEAD/Companion Materials (Books)/Applications (Net Code)/CLR/SQL Server 2008-2008R2/CLRTest/bin/Debug/CLRTest.dll -------------------------------------------------------------------------------- /Companion Materials (Books)/Applications (Net Code)/CLR/SQL Server 2008-2008R2/CLRTest/bin/Debug/CLRTest.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aboutsqlserver/code/HEAD/Companion Materials (Books)/Applications (Net Code)/CLR/SQL Server 2008-2008R2/CLRTest/bin/Debug/CLRTest.pdb -------------------------------------------------------------------------------- /Companion Materials (Books)/Applications (Net Code)/CLR/SQL Server 2012-2016/CLRTest/bin/Debug/CLRTest.dacpac: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aboutsqlserver/code/HEAD/Companion Materials (Books)/Applications (Net Code)/CLR/SQL Server 2012-2016/CLRTest/bin/Debug/CLRTest.dacpac -------------------------------------------------------------------------------- /Companion Materials (Books)/Applications (Net Code)/CLR/SQL Server 2008-2008R2/CLRTest/bin/Debug/CLRTest.dacpac: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aboutsqlserver/code/HEAD/Companion Materials (Books)/Applications (Net Code)/CLR/SQL Server 2008-2008R2/CLRTest/bin/Debug/CLRTest.dacpac -------------------------------------------------------------------------------- /Companion Materials (Books)/Applications (Net Code)/In-Memory OLTP/SessionStoreDemo/bin/Debug/SessionStoreDemo.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aboutsqlserver/code/HEAD/Companion Materials (Books)/Applications (Net Code)/In-Memory OLTP/SessionStoreDemo/bin/Debug/SessionStoreDemo.exe -------------------------------------------------------------------------------- /Companion Materials (Books)/Applications (Net Code)/In-Memory OLTP/SessionStoreDemo/bin/Debug/SessionStoreDemo.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aboutsqlserver/code/HEAD/Companion Materials (Books)/Applications (Net Code)/In-Memory OLTP/SessionStoreDemo/bin/Debug/SessionStoreDemo.pdb -------------------------------------------------------------------------------- /Companion Materials (Books)/Applications (Net Code)/In-Memory OLTP/SessionStoreDemo/bin/Debug/SessionStoreDemo.vshost.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aboutsqlserver/code/HEAD/Companion Materials (Books)/Applications (Net Code)/In-Memory OLTP/SessionStoreDemo/bin/Debug/SessionStoreDemo.vshost.exe -------------------------------------------------------------------------------- /Companion Materials (Books)/Applications (Net Code)/In-Memory OLTP/LogRequestsGenerator/bin/Debug/LogRequestsGenerator.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aboutsqlserver/code/HEAD/Companion Materials (Books)/Applications (Net Code)/In-Memory OLTP/LogRequestsGenerator/bin/Debug/LogRequestsGenerator.exe -------------------------------------------------------------------------------- /Companion Materials (Books)/Applications (Net Code)/In-Memory OLTP/LogRequestsGenerator/bin/Debug/LogRequestsGenerator.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aboutsqlserver/code/HEAD/Companion Materials (Books)/Applications (Net Code)/In-Memory OLTP/LogRequestsGenerator/bin/Debug/LogRequestsGenerator.pdb -------------------------------------------------------------------------------- /Companion Materials (Books)/Applications (Net Code)/In-Memory OLTP/SessionStoreDemo/bin/Debug/AboutSqlServer.Com.Classes.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aboutsqlserver/code/HEAD/Companion Materials (Books)/Applications (Net Code)/In-Memory OLTP/SessionStoreDemo/bin/Debug/AboutSqlServer.Com.Classes.dll -------------------------------------------------------------------------------- /Companion Materials (Books)/Applications (Net Code)/In-Memory OLTP/SessionStoreDemo/bin/Debug/AboutSqlServer.Com.Classes.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aboutsqlserver/code/HEAD/Companion Materials (Books)/Applications (Net Code)/In-Memory OLTP/SessionStoreDemo/bin/Debug/AboutSqlServer.Com.Classes.pdb -------------------------------------------------------------------------------- /Companion Materials (Books)/Applications (Net Code)/SaveRecordSet/SaveRecordSetApp/bin-.Net 3.5/Debug/SaveRecordSetApp.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aboutsqlserver/code/HEAD/Companion Materials (Books)/Applications (Net Code)/SaveRecordSet/SaveRecordSetApp/bin-.Net 3.5/Debug/SaveRecordSetApp.exe -------------------------------------------------------------------------------- /Companion Materials (Books)/Applications (Net Code)/SaveRecordSet/SaveRecordSetApp/bin-.Net 3.5/Debug/SaveRecordSetApp.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aboutsqlserver/code/HEAD/Companion Materials (Books)/Applications (Net Code)/SaveRecordSet/SaveRecordSetApp/bin-.Net 3.5/Debug/SaveRecordSetApp.pdb -------------------------------------------------------------------------------- /Companion Materials (Books)/Applications (Net Code)/SaveRecordSet/SaveRecordSetApp/bin-.Net 4.5/Debug/SaveRecordSetApp.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aboutsqlserver/code/HEAD/Companion Materials (Books)/Applications (Net Code)/SaveRecordSet/SaveRecordSetApp/bin-.Net 4.5/Debug/SaveRecordSetApp.exe -------------------------------------------------------------------------------- /Companion Materials (Books)/Applications (Net Code)/SaveRecordSet/SaveRecordSetApp/bin-.Net 4.5/Debug/SaveRecordSetApp.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aboutsqlserver/code/HEAD/Companion Materials (Books)/Applications (Net Code)/SaveRecordSet/SaveRecordSetApp/bin-.Net 4.5/Debug/SaveRecordSetApp.pdb -------------------------------------------------------------------------------- /Companion Materials (Books)/Expert SQL Server Transactions and Locking/04.Chapter 04 (Blocking In The System)/06.Capturing Blocking Info with Event Notifications.sql: -------------------------------------------------------------------------------- 1 | -- Use BMFramework Solution from companion materials of the book. 2 | -- Download the latest version from http://aboutsqlserver/bmframework -------------------------------------------------------------------------------- /Companion Materials (Books)/Applications (Net Code)/In-Memory OLTP/LogRequestsGenerator/bin/Debug/AboutSqlServer.Com.Classes.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aboutsqlserver/code/HEAD/Companion Materials (Books)/Applications (Net Code)/In-Memory OLTP/LogRequestsGenerator/bin/Debug/AboutSqlServer.Com.Classes.dll -------------------------------------------------------------------------------- /Companion Materials (Books)/Applications (Net Code)/In-Memory OLTP/LogRequestsGenerator/bin/Debug/AboutSqlServer.Com.Classes.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aboutsqlserver/code/HEAD/Companion Materials (Books)/Applications (Net Code)/In-Memory OLTP/LogRequestsGenerator/bin/Debug/AboutSqlServer.Com.Classes.pdb -------------------------------------------------------------------------------- /Companion Materials (Books)/Applications (Net Code)/In-Memory OLTP/LogRequestsGenerator/bin/Debug/LogRequestsGenerator.vshost.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aboutsqlserver/code/HEAD/Companion Materials (Books)/Applications (Net Code)/In-Memory OLTP/LogRequestsGenerator/bin/Debug/LogRequestsGenerator.vshost.exe -------------------------------------------------------------------------------- /Companion Materials (Books)/Applications (Net Code)/SaveRecordSet/SaveRecordSetApp/bin-.Net 3.5/Debug/SaveRecordSetApp.vshost.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aboutsqlserver/code/HEAD/Companion Materials (Books)/Applications (Net Code)/SaveRecordSet/SaveRecordSetApp/bin-.Net 3.5/Debug/SaveRecordSetApp.vshost.exe -------------------------------------------------------------------------------- /Companion Materials (Books)/Applications (Net Code)/SaveRecordSet/SaveRecordSetApp/bin-.Net 4.5/Debug/SaveRecordSetApp.vshost.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aboutsqlserver/code/HEAD/Companion Materials (Books)/Applications (Net Code)/SaveRecordSet/SaveRecordSetApp/bin-.Net 4.5/Debug/SaveRecordSetApp.vshost.exe -------------------------------------------------------------------------------- /Companion Materials (Books)/Applications (Net Code)/In-Memory OLTP/AboutSqlServer.Com.Classes/bin/Debug/AboutSqlServer.Com.Classes.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aboutsqlserver/code/HEAD/Companion Materials (Books)/Applications (Net Code)/In-Memory OLTP/AboutSqlServer.Com.Classes/bin/Debug/AboutSqlServer.Com.Classes.dll -------------------------------------------------------------------------------- /Companion Materials (Books)/Applications (Net Code)/In-Memory OLTP/AboutSqlServer.Com.Classes/bin/Debug/AboutSqlServer.Com.Classes.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aboutsqlserver/code/HEAD/Companion Materials (Books)/Applications (Net Code)/In-Memory OLTP/AboutSqlServer.Com.Classes/bin/Debug/AboutSqlServer.Com.Classes.pdb -------------------------------------------------------------------------------- /Companion Materials (Books)/Applications (Net Code)/Ad-Hoc Demo/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Companion Materials (Books)/SQL Server Advanced Troubleshooting And Performance Tuning/08.Locking, Blocking and Concurrency/03.1.Lock Escalation (Session 1).sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aboutsqlserver/code/HEAD/Companion Materials (Books)/SQL Server Advanced Troubleshooting And Performance Tuning/08.Locking, Blocking and Concurrency/03.1.Lock Escalation (Session 1).sql -------------------------------------------------------------------------------- /Companion Materials (Books)/Applications (Net Code)/In-Memory OLTP/SessionStoreDemo/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Companion Materials (Books)/Applications (Net Code)/SaveRecordSet/SaveRecordSetApp/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Companion Materials (Books)/Applications (Net Code)/In-Memory OLTP/LogRequestsGenerator/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Presentations/Intro Into Index Analysis/SQL/90.Redundant Indexes.sql: -------------------------------------------------------------------------------- 1 | /***************************************************************************************************************/ 2 | /* See https://github.com/aboutsqlserver/code/blob/main/Troubleshooting%20Scripts/20.Database%20Analysis.ipynb */ 3 | /***************************************************************************************************************/ 4 | -------------------------------------------------------------------------------- /Presentations/Intro Into Index Analysis/SQL/92.Index Usage from Plan Cache.sql: -------------------------------------------------------------------------------- 1 | /***************************************************************************************************************/ 2 | /* See https://github.com/aboutsqlserver/code/blob/main/Troubleshooting%20Scripts/20.Database%20Analysis.ipynb */ 3 | /***************************************************************************************************************/ 4 | -------------------------------------------------------------------------------- /Companion Materials (Books)/SQL Server Advanced Troubleshooting And Performance Tuning/README.txt: -------------------------------------------------------------------------------- 1 | Troubleshooting scripts used in the book are available in "/Troubleshooting Scripts" folder. 2 | Use Azure Data Studio (https://docs.microsoft.com/en-us/sql/azure-data-studio/download-azure-data-studio) to open the files. 3 | 4 | "/Companion Materials (Books)/Applications (Net Code)" provide the set of .Net applications to emulate some of scenarios discussed in the book. Check ReadMe file in the folder. 5 | -------------------------------------------------------------------------------- /Presentations/Intro Into Index Analysis/SQL/91.Table Info.sql: -------------------------------------------------------------------------------- 1 | /*************************************************************************/ 2 | /* See https://github.com/aboutsqlserver/code/tree/main/sp_IndexAnalysis */ 3 | /*************************************************************************/ 4 | EXEC master.dbo.sp_IndexAnalysis 5 | @Databases = 'CURRENT' 6 | ,@DestinationTable = NULL 7 | ,@CreateDestinationTable = 0 8 | ,@ReturnResultSet = 1 9 | ,@IncludeBufferPoolUsage = 1 10 | ,@Verbose = 0 -------------------------------------------------------------------------------- /Companion Materials (Books)/Applications (Net Code)/SaveRecordSet/SaveRecordSetApp/app.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /Companion Materials (Books)/Applications (Net Code)/SaveRecordSet/SaveRecordSetApp/bin-.Net 3.5/Debug/SaveRecordSetApp.exe.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /Companion Materials (Books)/Applications (Net Code)/SaveRecordSet/SaveRecordSetApp/bin-.Net 3.5/Debug/SaveRecordSetApp.vshost.exe.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /Companion Materials (Books)/Applications (Net Code)/README.txt: -------------------------------------------------------------------------------- 1 | Ad-Hoc Demo - Can be used to demonstrate compilation overhead and benefits of FORCED parameterization (Chapter 6 in "Advanced Troubleshooting and Performance Tuning" book) 2 | 3 | CLR - Examples for Chapter 14 and 15 of "Pro SQL Server Internals book" 4 | 5 | In-Memory OLTP - Examples for "Expert SQL Server In-Memory OLTP" and other books 6 | - LogRequestGenerator - Can also be used to illustrate page latches/hotspots in "Advanced Troubleshooting and Performance Tuning" book 7 | 8 | SaveRecordSet - compares performance of different methods to pass batch of rows to SQL Server 9 | 10 | -------------------------------------------------------------------------------- /Companion Materials (Books)/Applications (Net Code)/In-Memory OLTP/SessionStoreDemo/bin/Debug/SessionStoreDemo.vshost.exe.manifest: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /Companion Materials (Books)/Applications (Net Code)/SaveRecordSet/SaveRecordSetApp/bin-.Net 3.5/Debug/SaveRecordSetApp.vshost.exe.manifest: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /Companion Materials (Books)/Applications (Net Code)/SaveRecordSet/SaveRecordSetApp/bin-.Net 4.5/Debug/SaveRecordSetApp.exe.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /Companion Materials (Books)/Applications (Net Code)/SaveRecordSet/SaveRecordSetApp/bin-.Net 4.5/Debug/SaveRecordSetApp.vshost.exe.manifest: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /Companion Materials (Books)/Applications (Net Code)/Ad-Hoc Demo/App.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /Companion Materials (Books)/Applications (Net Code)/SaveRecordSet/SaveRecordSetApp/bin-.Net 4.5/Debug/SaveRecordSetApp.vshost.exe.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /Companion Materials (Books)/Applications (Net Code)/In-Memory OLTP/LogRequestsGenerator/App.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /Companion Materials (Books)/Applications (Net Code)/In-Memory OLTP/SessionStoreDemo/App.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /Companion Materials (Books)/Applications (Net Code)/Ad-Hoc Demo/bin/Debug/LogRequestsGenerator.exe.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /Companion Materials (Books)/Applications (Net Code)/Ad-Hoc Demo/bin/Debug/LogRequestsGenerator.vshost.exe.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /Companion Materials (Books)/Applications (Net Code)/Ad-Hoc Demo/bin/Debug/AdHocDemo.vshost.exe.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /Companion Materials (Books)/Applications (Net Code)/Ad-Hoc Demo/bin/Debug/AdHocDemo.exe.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /Companion Materials (Books)/Applications (Net Code)/In-Memory OLTP/LogRequestsGenerator/bin/Debug/LogRequestsGenerator.exe.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /Companion Materials (Books)/Applications (Net Code)/In-Memory OLTP/SessionStoreDemo/bin/Debug/SessionStoreDemo.exe.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /Companion Materials (Books)/Applications (Net Code)/In-Memory OLTP/LogRequestsGenerator/bin/Debug/LogRequestsGenerator.vshost.exe.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /Companion Materials (Books)/Applications (Net Code)/In-Memory OLTP/SessionStoreDemo/bin/Debug/SessionStoreDemo.vshost.exe.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # aboutsqlserver 2 | Dmitri Korotkevitch (aboutsqlserver.com) - SQL Server scripts and books companion materials 3 | 4 | Folders: 5 | 1. Troubleshooting Scripts - collection of SQL Server Troubleshooting and Diagnostics scripts. 6 | Use Azure Data Studio (https://docs.microsoft.com/en-us/sql/azure-data-studio/download-azure-data-studio) to open the files. 7 | 8 | 2. sp_IndexAnalysis - stored procedure that analyzes index properties along with their usage and operational metrics 9 | 10 | 3. Blocking Monitoring Framework - Blocking and Deadlock monitoring using Event Notification. See https://aboutsqlserver.com/bmframework for more details 11 | 12 | 4. Companion Materials - Books' companion materials 13 | 14 | 5. Presentations - Slides and demo code from presentations. More at: https://aboutsqlserver.com/presentations -------------------------------------------------------------------------------- /Companion Materials (Books)/Expert SQL Server In-Memory OLTP (1st Edition)/00.Init/00.Init.ssmssqlproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 00.Init.sql 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /Companion Materials (Books)/Expert SQL Server In-Memory OLTP (2nd Edition)/00.Init/00.Init.ssmssqlproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 00.Init.sql 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /Companion Materials (Books)/Pro SQL Server Internals 2nd Edition/00.Init/00.Init.ssmssqlproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 01.DB Creation.sql 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /Companion Materials (Books)/Expert SQL Server Transactions and Locking/00.Init/00.Init.ssmssqlproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 01.DB Creation.sql 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /Blocking Monitoring Framework/Setup/08.Set Version.sql: -------------------------------------------------------------------------------- 1 | /****************************************************************************/ 2 | /* Blocking Monitoring Framework */ 3 | /* */ 4 | /* Written by Dmitri V. Korotkevitch */ 5 | /* http://aboutsqlserver.com/bmframework */ 6 | /* dk@aboutsqlserver.com */ 7 | /****************************************************************************/ 8 | /* Initial Setup */ 9 | /* Set Version Number */ 10 | /****************************************************************************/ 11 | 12 | use DBA 13 | go 14 | 15 | exec dbo.SetVersion @Product = 'bmframework', @Version = '1.0.0'; 16 | -------------------------------------------------------------------------------- /Companion Materials (Books)/SQL Server Advanced Troubleshooting And Performance Tuning/00.Create Database/00.Create Database.ssmssqlproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 00.Create Database.sql 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /Companion Materials (Books)/Pro SQL Server Internals 1st Edition/14.Chapter 14 (CLR Types)/14.Chapter 14 (CLR Types) (SQL Server 2005).ssmssqlproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 01.UDT.sql 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /Companion Materials (Books)/Pro SQL Server Internals 2nd Edition/15.Chapter 15 (CLR Types)/15.Chapter 15 (CLR Types) (SQL Server 2005).ssmssqlproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 01.UDT.sql 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /Companion Materials (Books)/SQL Server Advanced Troubleshooting And Performance Tuning/07.Memory Issues/07.Memory Issues.ssmssqlproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 01.Memory-Intensive Query Optimization.sql 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /Companion Materials (Books)/Applications (Net Code)/SaveRecordSet/SaveRecordSet.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 11.00 3 | # Visual Studio 2010 4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SaveRecordSetApp", "SaveRecordSetApp\SaveRecordSetApp.csproj", "{49EAE681-0A5A-4897-B9A6-AE876CACB201}" 5 | EndProject 6 | Global 7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 8 | Debug|x86 = Debug|x86 9 | Release|x86 = Release|x86 10 | EndGlobalSection 11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 12 | {49EAE681-0A5A-4897-B9A6-AE876CACB201}.Debug|x86.ActiveCfg = Debug|x86 13 | {49EAE681-0A5A-4897-B9A6-AE876CACB201}.Debug|x86.Build.0 = Debug|x86 14 | {49EAE681-0A5A-4897-B9A6-AE876CACB201}.Release|x86.ActiveCfg = Release|x86 15 | {49EAE681-0A5A-4897-B9A6-AE876CACB201}.Release|x86.Build.0 = Release|x86 16 | EndGlobalSection 17 | GlobalSection(SolutionProperties) = preSolution 18 | HideSolutionNode = FALSE 19 | EndGlobalSection 20 | EndGlobal 21 | -------------------------------------------------------------------------------- /Companion Materials (Books)/SQL Server Advanced Troubleshooting And Performance Tuning/11.Transaction Log/11.Transaction Log.ssmssqlproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 01.Explicit and Autocommitted Transactions.sql 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /Companion Materials (Books)/Pro SQL Server Internals 1st Edition/04.Chapter 04 (Special Features)/04.Chapter 04 (Special Features) (SQL Server 2005).ssmssqlproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 04.Calculated Columns.sql 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /Companion Materials (Books)/Pro SQL Server Internals 1st Edition/29.Chapter 29 (Transaction Log Internals)/29.Chapter 29 (Transaction Log Internals).ssmssqlproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 01.Troubleshooting Log Growth.sql 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /Companion Materials (Books)/Pro SQL Server Internals 2nd Edition/30.Chapter 30 (Transaction Log Internals)/30.Chapter 30 (Transaction Log Internals).ssmssqlproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 01.Troubleshooting Log Growth.sql 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /Companion Materials (Books)/Pro SQL Server Internals 2nd Edition/34.Chapter 34 (Columnstore Indexes)/34.Chapter 34 (Columnstore Indexes) (SQL Server 2012).ssmssqlproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 01.Switching Partition.sql 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /Companion Materials (Books)/Expert SQL Server In-Memory OLTP (1st Edition)/08.Chapter 08 (Data Storage, Logging and Recovery)/08.Chapter 08 (Data Storage, Logging and Recovery).ssmssqlproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 01.Tran Logging.sql 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /Companion Materials (Books)/Expert SQL Server In-Memory OLTP (2nd Edition)/17.Appendix D (In-Memory OLTP Migration Tools)/17.Appendix D (In-Memory OLTP Migration Tools).ssmssqlproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 01.Creating On-Disk Objects.sql 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /Presentations/Intro Into Index Analysis/SQL/IndexAnalysis.ssmssln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # SQL Server Management Studio Solution File, Format Version 18.00 4 | VisualStudioVersion = 15.0.28307.421 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{4F2E2C19-372F-40D8-9FA7-9D2138C6997A}") = "IndexAnalysis", "IndexAnalysis.ssmssqlproj", "{3D12D365-75A4-4DEE-8A81-509C0300D83B}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Default|Default = Default|Default 11 | EndGlobalSection 12 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 13 | {3D12D365-75A4-4DEE-8A81-509C0300D83B}.Default|Default.ActiveCfg = Default 14 | {83AECC02-FE72-4E76-A08E-619DB1CFEE51}.Default|Default.ActiveCfg = Default 15 | EndGlobalSection 16 | GlobalSection(SolutionProperties) = preSolution 17 | HideSolutionNode = FALSE 18 | EndGlobalSection 19 | GlobalSection(ExtensibilityGlobals) = postSolution 20 | SolutionGuid = {0395DD94-CDB7-4C9E-BCCA-5A1FA76C15EE} 21 | EndGlobalSection 22 | EndGlobal 23 | -------------------------------------------------------------------------------- /Blocking Monitoring Framework/Testing/01.2.Blocking Testing (Session 2).sql: -------------------------------------------------------------------------------- 1 | /****************************************************************************/ 2 | /* Blocking Monitoring Framework */ 3 | /* */ 4 | /* Written by Dmitri V. Korotkevitch */ 5 | /* http://aboutsqlserver.com/bmframework */ 6 | /* dk@aboutsqlserver.com */ 7 | /****************************************************************************/ 8 | /* Testing */ 9 | /* Testing Blocking Event Notification */ 10 | /* (Session 2) */ 11 | /****************************************************************************/ 12 | 13 | use tempdb 14 | go 15 | 16 | -- Session 2 code 17 | select count(*) 18 | from tempdb.dbo.Data with (readcommitted); 19 | go 20 | -------------------------------------------------------------------------------- /Companion Materials (Books)/Pro SQL Server Internals 1st Edition/27.Chapter 27 (System Troubleshooting)/06.Enable Remote DAC.sql: -------------------------------------------------------------------------------- 1 | /****************************************************************************/ 2 | /* Pro SQL Server Internals */ 3 | /* APress. 1st Edition. ISBN-13: 978-1430259626 ISBN-10:1430259620 */ 4 | /* */ 5 | /* Written by Dmitri V. Korotkevitch */ 6 | /* http://aboutsqlserver.com */ 7 | /* dmitri@aboutsqlserver.com */ 8 | /****************************************************************************/ 9 | /* Chapter 27. System Troubleshooting */ 10 | /* Enable Remote DAC Connection */ 11 | /****************************************************************************/ 12 | 13 | exec sp_configure 'remote admin connections', 1 14 | go 15 | reconfigure 16 | go 17 | -------------------------------------------------------------------------------- /Companion Materials (Books)/Pro SQL Server Internals 2nd Edition/28.Chapter 28 (System Troubleshooting)/06.Enable Remote DAC.sql: -------------------------------------------------------------------------------- 1 | /****************************************************************************/ 2 | /* Pro SQL Server Internals */ 3 | /* APress. 2nd Edition. ISBN-13: 978-1484219638 ISBN-10:1484219635 */ 4 | /* */ 5 | /* Written by Dmitri V. Korotkevitch */ 6 | /* http://aboutsqlserver.com */ 7 | /* dk@aboutsqlserver.com */ 8 | /****************************************************************************/ 9 | /* Chapter 28. System Troubleshooting */ 10 | /* Enable Remote DAC Connection */ 11 | /****************************************************************************/ 12 | 13 | exec sp_configure 'remote admin connections', 1 ; 14 | go 15 | reconfigure; 16 | go 17 | -------------------------------------------------------------------------------- /Companion Materials (Books)/Expert SQL Server Transactions and Locking/14.Chapter 14 (Locking and Columnstore Indexes)/02.2.Insert.sql: -------------------------------------------------------------------------------- 1 | /****************************************************************************/ 2 | /* Expert SQL Server Transactions and Locking */ 3 | /* APress. ISBN-13: 978-1484239568 ISBN-10: 1484239563 */ 4 | /* */ 5 | /* Written by Dmitri V. Korotkevitch */ 6 | /* http://aboutsqlserver.com */ 7 | /* dk@aboutsqlserver.com */ 8 | /****************************************************************************/ 9 | /* Chapter 14. Locking and Columnstore Indexes */ 10 | /* Append Workload (Session 2) */ 11 | /****************************************************************************/ 12 | 13 | use SQLServerInternals 14 | go 15 | 16 | insert into dbo.Test(ID, Col) 17 | values(-2,-2); -------------------------------------------------------------------------------- /Companion Materials (Books)/Expert SQL Server Transactions and Locking/14.Chapter 14 (Locking and Columnstore Indexes)/03.2.Update.sql: -------------------------------------------------------------------------------- 1 | /****************************************************************************/ 2 | /* Expert SQL Server Transactions and Locking */ 3 | /* APress. ISBN-13: 978-1484239568 ISBN-10: 1484239563 */ 4 | /* */ 5 | /* Written by Dmitri V. Korotkevitch */ 6 | /* http://aboutsqlserver.com */ 7 | /* dk@aboutsqlserver.com */ 8 | /****************************************************************************/ 9 | /* Chapter 14. Locking and Columnstore Indexes */ 10 | /* Update Workload (Session 2) */ 11 | /****************************************************************************/ 12 | 13 | use SQLServerInternals 14 | go 15 | 16 | update dbo.Test 17 | set Col += 1 18 | where ID=10; -------------------------------------------------------------------------------- /Companion Materials (Books)/Expert SQL Server Transactions and Locking/08.Chapter 08 (Schema and Low Priority Locks)/01.2.Schema Locks.sql: -------------------------------------------------------------------------------- 1 | /****************************************************************************/ 2 | /* Expert SQL Server Transactions and Locking */ 3 | /* APress. ISBN-13: 978-1484239568 ISBN-10: 1484239563 */ 4 | /* */ 5 | /* Written by Dmitri V. Korotkevitch */ 6 | /* http://aboutsqlserver.com */ 7 | /* dk@aboutsqlserver.com */ 8 | /****************************************************************************/ 9 | /* Chapter 08. Schema Locks */ 10 | /* Schema Lock Demo (Session 2) */ 11 | /****************************************************************************/ 12 | 13 | use SQLServerInternals 14 | go 15 | 16 | select count(*) 17 | from Delivery.Orders with (nolock); 18 | go -------------------------------------------------------------------------------- /Companion Materials (Books)/Expert SQL Server Transactions and Locking/12.Chapter 12 (Troubleshooting Concurrency Issues)/06.3.Blocking Chains.sql: -------------------------------------------------------------------------------- 1 | /****************************************************************************/ 2 | /* Expert SQL Server Transactions and Locking */ 3 | /* APress. ISBN-13: 978-1484239568 ISBN-10: 1484239563 */ 4 | /* */ 5 | /* Written by Dmitri V. Korotkevitch */ 6 | /* http://aboutsqlserver.com */ 7 | /* dk@aboutsqlserver.com */ 8 | /****************************************************************************/ 9 | /* Chapter 12. Troubleshooting Concurrency Issues */ 10 | /* Blocking Chain (Session 3) */ 11 | /****************************************************************************/ 12 | 13 | use SQLServerInternals 14 | go 15 | 16 | select count(*) 17 | from Delivery.Orders with (tablock); -------------------------------------------------------------------------------- /Companion Materials (Books)/Expert SQL Server Transactions and Locking/14.Chapter 14 (Locking and Columnstore Indexes)/04.2.Delete.sql: -------------------------------------------------------------------------------- 1 | /****************************************************************************/ 2 | /* Expert SQL Server Transactions and Locking */ 3 | /* APress. ISBN-13: 978-1484239568 ISBN-10: 1484239563 */ 4 | /* */ 5 | /* Written by Dmitri V. Korotkevitch */ 6 | /* http://aboutsqlserver.com */ 7 | /* dk@aboutsqlserver.com */ 8 | /****************************************************************************/ 9 | /* Chapter 14. Locking and Columnstore Indexes */ 10 | /* Delete Workload (Session 2) */ 11 | /****************************************************************************/ 12 | 13 | use SQLServerInternals 14 | go 15 | 16 | -- Test 3: Locking during deletes 17 | delete from dbo.Test 18 | where ID=50; -------------------------------------------------------------------------------- /Blocking Monitoring Framework/Setup/05.1.Security (Trustworthy).sql: -------------------------------------------------------------------------------- 1 | /****************************************************************************/ 2 | /* Blocking Monitoring Framework */ 3 | /* */ 4 | /* Written by Dmitri V. Korotkevitch */ 5 | /* http://aboutsqlserver.com/bmframework */ 6 | /* dk@aboutsqlserver.com */ 7 | /****************************************************************************/ 8 | /* Initial Setup */ 9 | /* Setting Up Security */ 10 | /****************************************************************************/ 11 | 12 | 13 | -- Simple security setup can be done by enabling TRUSTWORTHY on DBA database. 14 | -- Alternatively, you can set up cert-based security using script 05.2.Security(Certs).sql 15 | 16 | use master 17 | go 18 | 19 | alter database DBA set trustworthy on 20 | go 21 | -------------------------------------------------------------------------------- /Companion Materials (Books)/Expert SQL Server Transactions and Locking/12.Chapter 12 (Troubleshooting Concurrency Issues)/06.4.Blocking Chains.sql: -------------------------------------------------------------------------------- 1 | /****************************************************************************/ 2 | /* Expert SQL Server Transactions and Locking */ 3 | /* APress. ISBN-13: 978-1484239568 ISBN-10: 1484239563 */ 4 | /* */ 5 | /* Written by Dmitri V. Korotkevitch */ 6 | /* http://aboutsqlserver.com */ 7 | /* dk@aboutsqlserver.com */ 8 | /****************************************************************************/ 9 | /* Chapter 12. Troubleshooting Concurrency Issues */ 10 | /* Blocking Chain (Session 4) */ 11 | /****************************************************************************/ 12 | 13 | use SQLServerInternals 14 | go 15 | 16 | update Delivery.Orders 17 | set Pieces += 1 18 | where OrderId = 100; 19 | 20 | -------------------------------------------------------------------------------- /Companion Materials (Books)/Expert SQL Server Transactions and Locking/08.Chapter 08 (Schema and Low Priority Locks)/01.3.Schema Locks.sql: -------------------------------------------------------------------------------- 1 | /****************************************************************************/ 2 | /* Expert SQL Server Transactions and Locking */ 3 | /* APress. ISBN-13: 978-1484239568 ISBN-10: 1484239563 */ 4 | /* */ 5 | /* Written by Dmitri V. Korotkevitch */ 6 | /* http://aboutsqlserver.com */ 7 | /* dk@aboutsqlserver.com */ 8 | /****************************************************************************/ 9 | /* Chapter 08. Schema Locks */ 10 | /* Schema Lock Demo (Session 3) */ 11 | /****************************************************************************/ 12 | 13 | use SQLServerInternals 14 | go 15 | 16 | begin tran 17 | delete 18 | from Delivery.Orders 19 | where OrderId = 1; 20 | rollback 21 | go 22 | -------------------------------------------------------------------------------- /Companion Materials (Books)/Expert SQL Server Transactions and Locking/06.Chapter 06 (Optimistic Isolation Levels)/03.2.Error 3960.sql: -------------------------------------------------------------------------------- 1 | /****************************************************************************/ 2 | /* Expert SQL Server Transactions and Locking */ 3 | /* APress. ISBN-13: 978-1484239568 ISBN-10: 1484239563 */ 4 | /* */ 5 | /* Written by Dmitri V. Korotkevitch */ 6 | /* http://aboutsqlserver.com */ 7 | /* dk@aboutsqlserver.com */ 8 | /****************************************************************************/ 9 | /* Chapter 06. Optimistic Isolation Levels */ 10 | /* Snapshot Isolation and Error 3960 (Session 2) */ 11 | /****************************************************************************/ 12 | 13 | use SQLServerInternals 14 | go 15 | 16 | update Delivery.Orders 17 | set Reference = convert(varchar(48),newid()) 18 | where OrderId = 1; 19 | go 20 | 21 | -------------------------------------------------------------------------------- /Companion Materials (Books)/Pro SQL Server Internals 1st Edition/00.Init/00.Init.ssmssqlproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 01.DB Creation.sql 14 | 15 | 16 | 17 | 18 | 19 | 02.Part 5 Objects.sql 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Companion Materials (Books)/Expert SQL Server Transactions and Locking/10.Chapter 10 (Application Locks)/02.2.Application Locks.sql: -------------------------------------------------------------------------------- 1 | /****************************************************************************/ 2 | /* Expert SQL Server Transactions and Locking */ 3 | /* APress. ISBN-13: 978-1484239568 ISBN-10: 1484239563 */ 4 | /* */ 5 | /* Written by Dmitri V. Korotkevitch */ 6 | /* http://aboutsqlserver.com */ 7 | /* dk@aboutsqlserver.com */ 8 | /****************************************************************************/ 9 | /* Chapter 10. Application Locks */ 10 | /* Application Locks (Session 2) */ 11 | /****************************************************************************/ 12 | 13 | set nocount on 14 | go 15 | 16 | use SQLServerInternals 17 | go 18 | 19 | -- Session 2 code 20 | exec dbo.LoadRawData @PacketSize = 50; 21 | go 22 | -------------------------------------------------------------------------------- /Companion Materials (Books)/Expert SQL Server Transactions and Locking/12.Chapter 12 (Troubleshooting Concurrency Issues)/08.2.Readable Secondaries.sql: -------------------------------------------------------------------------------- 1 | /****************************************************************************/ 2 | /* Expert SQL Server Transactions and Locking */ 3 | /* APress. ISBN-13: 978-1484239568 ISBN-10: 1484239563 */ 4 | /* */ 5 | /* Written by Dmitri V. Korotkevitch */ 6 | /* http://aboutsqlserver.com */ 7 | /* dk@aboutsqlserver.com */ 8 | /****************************************************************************/ 9 | /* Chapter 12. Troubleshooting Concurrency Issues */ 10 | /* Readable Secondaries (Session 1) */ 11 | /****************************************************************************/ 12 | 13 | -- Run on readable secondary node!! 14 | 15 | use SQLServerInternals 16 | go 17 | 18 | begin tran 19 | select * from dbo.T2; 20 | -------------------------------------------------------------------------------- /Companion Materials (Books)/SQL Server Advanced Troubleshooting And Performance Tuning/08.Locking, Blocking and Concurrency/01.2.Blocking (Session 2).sql: -------------------------------------------------------------------------------- 1 | /****************************************************************************/ 2 | /* SQL Server Advanced Troubleshooting and Performance Tuning */ 3 | /* O'Reilly, 2022. ISBN-13: 978-1098101923 ISBN-10: 1098101928 */ 4 | /* */ 5 | /* Written by Dmitri V. Korotkevitch */ 6 | /* https://aboutsqlserver.com */ 7 | /* dk@aboutsqlserver.com */ 8 | /****************************************************************************/ 9 | /* Chapter 08: Locking, Blocking and Concurrency */ 10 | /* Blocking Condition (Session 1) */ 11 | /****************************************************************************/ 12 | 13 | USE SQLServerInternals 14 | GO 15 | 16 | SELECT OrderId, Amount 17 | FROM dbo.Orders WITH (READCOMMITTEDLOCK) 18 | WHERE OrderNum = '100'; -------------------------------------------------------------------------------- /Blocking Monitoring Framework/Analysis/Analysis.ssmssqlproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 01.Blocking Analysis Queries.sql 14 | 15 | 16 | 17 | 18 | 19 | 02.Deadlock Analysis Queries.sql 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Companion Materials (Books)/Applications (Net Code)/Ad-Hoc Demo/Program.cs: -------------------------------------------------------------------------------- 1 | /****************************************************************************/ 2 | /* Cautionary Tale of Recompilations, Excessive CPU Load and Plan Caching */ 3 | /* Dmitri V. Korotkevitch */ 4 | /* http://aboutsqlserver.com */ 5 | /* dk@aboutsqlserver.com */ 6 | /****************************************************************************/ 7 | 8 | using System; 9 | using System.Collections.Generic; 10 | using System.Linq; 11 | using System.Threading.Tasks; 12 | using System.Windows.Forms; 13 | 14 | namespace Actsoft.Com.AdHocDemo 15 | { 16 | static class Program 17 | { 18 | /// 19 | /// The main entry point for the application. 20 | /// 21 | [STAThread] 22 | static void Main() 23 | { 24 | Application.EnableVisualStyles(); 25 | Application.SetCompatibleTextRenderingDefault(false); 26 | Application.Run(new frmMain()); 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Companion Materials (Books)/Pro SQL Server Internals 1st Edition/19.Chapter 19 (Deadlocks)/03.2.Multiple Updates.sql: -------------------------------------------------------------------------------- 1 | /****************************************************************************/ 2 | /* Pro SQL Server Internals */ 3 | /* APress. 1st Edition. ISBN-13: 978-1430259626 ISBN-10:1430259620 */ 4 | /* */ 5 | /* Written by Dmitri V. Korotkevitch */ 6 | /* http://aboutsqlserver.com */ 7 | /* dmitri@aboutsqlserver.com */ 8 | /****************************************************************************/ 9 | /* Chapter 19. Deadlocks */ 10 | /* Deadlock Due to Multiple Updates (Session 2) */ 11 | /****************************************************************************/ 12 | 13 | set nocount on 14 | go 15 | 16 | use [SqlServerInternals] 17 | go 18 | 19 | select top 10 ID, Value, ModTime 20 | from dbo.Data 21 | where ModTime > '2001-01-01' 22 | order by ModTime, ID -------------------------------------------------------------------------------- /Companion Materials (Books)/Pro SQL Server Internals 2nd Edition/19.Chapter 19 (Deadlocks)/03.2.Multiple Updates.sql: -------------------------------------------------------------------------------- 1 | /****************************************************************************/ 2 | /* Pro SQL Server Internals */ 3 | /* APress. 2nd Edition. ISBN-13: 978-1484219638 ISBN-10:1484219635 */ 4 | /* */ 5 | /* Written by Dmitri V. Korotkevitch */ 6 | /* http://aboutsqlserver.com */ 7 | /* dk@aboutsqlserver.com */ 8 | /****************************************************************************/ 9 | /* Chapter 19. Deadlocks */ 10 | /* Deadlock Due to Multiple Updates (Session 2) */ 11 | /****************************************************************************/ 12 | 13 | set nocount on 14 | go 15 | 16 | use [SqlServerInternals] 17 | go 18 | 19 | select top 10 ID, Value, ModTime 20 | from dbo.Data 21 | where ModTime > '2001-01-01' 22 | order by ModTime, ID; -------------------------------------------------------------------------------- /Companion Materials (Books)/Expert SQL Server Transactions and Locking/05.Chapter 05 (Deadlocks)/03.2.Multiple Updates.sql: -------------------------------------------------------------------------------- 1 | /****************************************************************************/ 2 | /* Expert SQL Server Transactions and Locking */ 3 | /* APress. ISBN-13: 978-1484239568 ISBN-10: 1484239563 */ 4 | /* */ 5 | /* Written by Dmitri V. Korotkevitch */ 6 | /* http://aboutsqlserver.com */ 7 | /* dk@aboutsqlserver.com */ 8 | /****************************************************************************/ 9 | /* Chapter 05. Deadlocks */ 10 | /* Deadlock Due to Multiple Updates (Session 2) */ 11 | /****************************************************************************/ 12 | 13 | set nocount on 14 | go 15 | 16 | use SQLServerInternals 17 | go 18 | 19 | select top 10 ID, Value, ModTime 20 | from dbo.Data 21 | where ModTime > '2001-01-01' 22 | order by ModTime, ID; -------------------------------------------------------------------------------- /Companion Materials (Books)/Expert SQL Server Transactions and Locking/04.Chapter 04 (Blocking In The System)/01.2.Creating Blocking.sql: -------------------------------------------------------------------------------- 1 | /****************************************************************************/ 2 | /* Expert SQL Server Transactions and Locking */ 3 | /* APress. ISBN-13: 978-1484239568 ISBN-10: 1484239563 */ 4 | /* */ 5 | /* Written by Dmitri V. Korotkevitch */ 6 | /* http://aboutsqlserver.com */ 7 | /* dk@aboutsqlserver.com */ 8 | /****************************************************************************/ 9 | /* Chapter 04.Blocking In The System */ 10 | /* Create Blocking Condition (Session 2) */ 11 | /****************************************************************************/ 12 | 13 | use SQLServerInternals 14 | go 15 | 16 | set transaction isolation level read committed 17 | select OrderId, Amount 18 | from Delivery.Orders 19 | where OrderNum = '1000'; -------------------------------------------------------------------------------- /Companion Materials (Books)/SQL Server Advanced Troubleshooting And Performance Tuning/10.Latches/10.Latches.ssmssqlproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 01.Hotspots.sql 14 | 15 | 16 | 17 | 18 | 19 | 02.Hash Partitioning.sql 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Companion Materials (Books)/Pro SQL Server Internals 1st Edition/18.Chapter 18 (Troubleshooting Blocking Issues)/03.Set Blocked Process Threshold.sql: -------------------------------------------------------------------------------- 1 | /****************************************************************************/ 2 | /* Pro SQL Server Internals */ 3 | /* APress. 1st Edition. ISBN-13: 978-1430259626 ISBN-10:1430259620 */ 4 | /* */ 5 | /* Written by Dmitri V. Korotkevitch */ 6 | /* http://aboutsqlserver.com */ 7 | /* dmitri@aboutsqlserver.com */ 8 | /****************************************************************************/ 9 | /* Chapter 18. Troubleshooting Blocking Issues */ 10 | /* Setting Blocked Process Threshold */ 11 | /****************************************************************************/ 12 | 13 | sp_configure 'show advanced options', 1; 14 | go 15 | reconfigure; 16 | go 17 | sp_configure 'blocked process threshold', 20; 18 | go 19 | reconfigure; 20 | go 21 | -------------------------------------------------------------------------------- /Blocking Monitoring Framework/Testing/02.2.Deadlock Testing (Session 2).sql: -------------------------------------------------------------------------------- 1 | /****************************************************************************/ 2 | /* Blocking Monitoring Framework */ 3 | /* */ 4 | /* Written by Dmitri V. Korotkevitch */ 5 | /* http://aboutsqlserver.com/bmframework */ 6 | /* dk@aboutsqlserver.com */ 7 | /****************************************************************************/ 8 | /* Testing */ 9 | /* Testing Deadlocks Notification */ 10 | /* (Session 2) */ 11 | /****************************************************************************/ 12 | 13 | use tempdb 14 | go 15 | 16 | -- Session 2 code 17 | begin tran 18 | update dbo.Data 19 | set Value = Value + 1 20 | where ID = 4; 21 | 22 | select count(*) 23 | from dbo.Data with (tablock) 24 | commit 25 | go 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /Companion Materials (Books)/Expert SQL Server Transactions and Locking/04.Chapter 04 (Blocking In The System)/03.Set Blocked Process Threshold.sql: -------------------------------------------------------------------------------- 1 | /****************************************************************************/ 2 | /* Expert SQL Server Transactions and Locking */ 3 | /* APress. ISBN-13: 978-1484239568 ISBN-10: 1484239563 */ 4 | /* */ 5 | /* Written by Dmitri V. Korotkevitch */ 6 | /* http://aboutsqlserver.com */ 7 | /* dk@aboutsqlserver.com */ 8 | /****************************************************************************/ 9 | /* Chapter 04.Blocking In The System */ 10 | /* Setting Blocked Process Threshold */ 11 | /****************************************************************************/ 12 | 13 | sp_configure 'show advanced options', 1; 14 | go 15 | reconfigure; 16 | go 17 | sp_configure 'blocked process threshold', 10; -- In seconds. 18 | go 19 | reconfigure; 20 | go 21 | -------------------------------------------------------------------------------- /Companion Materials (Books)/Expert SQL Server Transactions and Locking/12.Chapter 12 (Troubleshooting Concurrency Issues)/03.Wait Type Map.sql: -------------------------------------------------------------------------------- 1 | /****************************************************************************/ 2 | /* Expert SQL Server Transactions and Locking */ 3 | /* APress. ISBN-13: 978-1484239568 ISBN-10: 1484239563 */ 4 | /* */ 5 | /* Written by Dmitri V. Korotkevitch */ 6 | /* http://aboutsqlserver.com */ 7 | /* dk@aboutsqlserver.com */ 8 | /****************************************************************************/ 9 | /* Chapter 12. Troubleshooting Concurrency Issues */ 10 | /* Wait Type Map Values */ 11 | /****************************************************************************/ 12 | 13 | -- Identifying map type values for wait_info Extended Event 14 | select name, map_key, map_value 15 | from sys.dm_xe_map_values 16 | where name = 'wait_types' 17 | order by map_key 18 | -------------------------------------------------------------------------------- /Companion Materials (Books)/Pro SQL Server Internals 1st Edition/07.Chapter 07 (Constraints)/07.Chapter 07 (Constraints).ssmssqlproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 01.FK.sql 14 | 15 | 16 | 17 | 18 | 19 | 02.Check Constraints.sql 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Companion Materials (Books)/Pro SQL Server Internals 2nd Edition/18.Chapter 18 (Troubleshooting Blocking Issues)/03.Set Blocked Process Threshold.sql: -------------------------------------------------------------------------------- 1 | /****************************************************************************/ 2 | /* Pro SQL Server Internals */ 3 | /* APress. 2nd Edition. ISBN-13: 978-1484219638 ISBN-10:1484219635 */ 4 | /* */ 5 | /* Written by Dmitri V. Korotkevitch */ 6 | /* http://aboutsqlserver.com */ 7 | /* dk@aboutsqlserver.com */ 8 | /****************************************************************************/ 9 | /* Chapter 18. Troubleshooting Blocking Issues */ 10 | /* Setting Blocked Process Threshold */ 11 | /****************************************************************************/ 12 | 13 | sp_configure 'show advanced options', 1; 14 | go 15 | reconfigure; 16 | go 17 | sp_configure 'blocked process threshold', 20; -- In seconds. 18 | go 19 | reconfigure; 20 | go 21 | -------------------------------------------------------------------------------- /Companion Materials (Books)/Expert SQL Server Transactions and Locking/14.Chapter 14 (Locking and Columnstore Indexes)/05.Create NCI.sql: -------------------------------------------------------------------------------- 1 | /****************************************************************************/ 2 | /* Expert SQL Server Transactions and Locking */ 3 | /* APress. ISBN-13: 978-1484239568 ISBN-10: 1484239563 */ 4 | /* */ 5 | /* Written by Dmitri V. Korotkevitch */ 6 | /* http://aboutsqlserver.com */ 7 | /* dk@aboutsqlserver.com */ 8 | /****************************************************************************/ 9 | /* Chapter 14. Locking and Columnstore Indexes */ 10 | /* Creating Nonclustered B-Tree Index */ 11 | /****************************************************************************/ 12 | 13 | use SQLServerInternals 14 | go 15 | 16 | 17 | create nonclustered index IDX_Test_ID 18 | on dbo.Test(ID); 19 | go 20 | 21 | -- Repeat UPDATE and DELETE tests and notice that blocking disappeared -------------------------------------------------------------------------------- /Companion Materials (Books)/Expert SQL Server In-Memory OLTP (2nd Edition)/08.Chapter 08 (Transaction Processing)/07.2.Ref Integrity.sql: -------------------------------------------------------------------------------- 1 | /****************************************************************************/ 2 | /* Expert SQL Server In-Memory OLTP */ 3 | /* APress. 2nd Edition. ISBN-13:978-1484227718 ISBN-10:1484227719 */ 4 | /* */ 5 | /* Written by Dmitri V. Korotkevitch */ 6 | /* http://aboutsqlserver.com */ 7 | /* dk@aboutsqlserver.com */ 8 | /****************************************************************************/ 9 | /* Chapter 08: Transaction Processing in In-Memory OLTP */ 10 | /* 07.Referential Integrity Enforcement (Session21) */ 11 | /****************************************************************************/ 12 | 13 | set nocount on 14 | go 15 | 16 | use InMemoryOLTP2016 17 | go 18 | 19 | 20 | --Session 2 code 21 | update dbo.Transactions with (snapshot) 22 | set Amount = 30 23 | where TransactionId = 2; 24 | 25 | -------------------------------------------------------------------------------- /Companion Materials (Books)/Pro SQL Server Internals 2nd Edition/00.Init/00.Init (SQL Server 2014-2016).ssmssqlproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 01.DB Creation.sql 14 | 15 | 16 | 17 | 18 | 19 | 02.Create In-Memory OLTP DB.sql 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Companion Materials (Books)/Pro SQL Server Internals 2nd Edition/08.Chapter 08 (Constraints)/08.Chapter 08 (Constraints).ssmssqlproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 01.FK.sql 14 | 15 | 16 | 17 | 18 | 19 | 02.Check Constraints Overhead.sql 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Blocking Monitoring Framework/Testing/02.1.Deadlock Testing (Session 1).sql: -------------------------------------------------------------------------------- 1 | /****************************************************************************/ 2 | /* Blocking Monitoring Framework */ 3 | /* */ 4 | /* Written by Dmitri V. Korotkevitch */ 5 | /* http://aboutsqlserver.com/bmframework */ 6 | /* dk@aboutsqlserver.com */ 7 | /****************************************************************************/ 8 | /* Testing */ 9 | /* Testing Deadlocks Notification */ 10 | /* (Session 1) */ 11 | /****************************************************************************/ 12 | 13 | use tempdb 14 | go 15 | 16 | -- Session 1 code 17 | begin tran 18 | update dbo.Data 19 | set Value = Value + 1 20 | where ID = 1; 21 | 22 | -- run session 2 code 23 | select count(*) 24 | from dbo.Data with (tablockx) 25 | commit 26 | go 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /Companion Materials (Books)/SQL Server Advanced Troubleshooting And Performance Tuning/08.Locking, Blocking and Concurrency/03.2.Lock Escalation (Session 2).sql: -------------------------------------------------------------------------------- 1 | /****************************************************************************/ 2 | /* SQL Server Advanced Troubleshooting and Performance Tuning */ 3 | /* O'Reilly, 2022. ISBN-13: 978-1098101923 ISBN-10: 1098101928 */ 4 | /* */ 5 | /* Written by Dmitri V. Korotkevitch */ 6 | /* https://aboutsqlserver.com */ 7 | /* dk@aboutsqlserver.com */ 8 | /****************************************************************************/ 9 | /* Chapter 08: Locking, Blocking and Concurrency */ 10 | /* Lock Escalation (Session 2) */ 11 | /****************************************************************************/ 12 | 13 | USE SQLServerInternals 14 | GO 15 | 16 | BEGIN TRAN 17 | INSERT INTO dbo.Orders(OrderId,OrderNum,OrderDate,CustomerId,Amount,OrderStatus) 18 | VALUES(100000,'100000',GETDATE(),1,100,0); 19 | ROLLBACK -------------------------------------------------------------------------------- /Blocking Monitoring Framework/Testing/01.1.Blocking Testing (Session 1).sql: -------------------------------------------------------------------------------- 1 | /****************************************************************************/ 2 | /* Blocking Monitoring Framework */ 3 | /* */ 4 | /* Written by Dmitri V. Korotkevitch */ 5 | /* http://aboutsqlserver.com/bmframework */ 6 | /* dk@aboutsqlserver.com */ 7 | /****************************************************************************/ 8 | /* Testing */ 9 | /* Testing Blocking Event Notification */ 10 | /* (Session 1) */ 11 | /****************************************************************************/ 12 | 13 | use tempdb 14 | go 15 | 16 | -- Emulate blocking 17 | -- Session 1 code 18 | begin tran 19 | update dbo.Data with (tablockx) 20 | set Value = Value + 1 21 | where ID = 2; 22 | 23 | -- run session 2 code below and wait for some time 24 | commit 25 | go 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /Companion Materials (Books)/Expert SQL Server In-Memory OLTP (1st Edition)/06.Chapter 06 (In-Memory OLTP Programmability)/02.2.Atomic Blocks.sql: -------------------------------------------------------------------------------- 1 | /****************************************************************************/ 2 | /* Expert SQL Server In-Memory OLTP */ 3 | /* APress. 1st Edition. ISBN-13:978-1484211373 ISBN-10:1484211375 */ 4 | /* */ 5 | /* Written by Dmitri V. Korotkevitch */ 6 | /* http://aboutsqlserver.com */ 7 | /* dk@aboutsqlserver.com */ 8 | /****************************************************************************/ 9 | /* Chapter 06: In-Memory OLTP Programmability */ 10 | /* 02.Atomic Blocks (Session 2) */ 11 | /****************************************************************************/ 12 | 13 | set nocount on 14 | go 15 | 16 | use InMemoryOLTP2014 17 | go 18 | 19 | 20 | /*** Critical Errors ***/ 21 | -- Run together with Session 1 code 22 | begin tran 23 | exec dbo.AtomicBlockDemo 1, 0, null, null 24 | 25 | -------------------------------------------------------------------------------- /Companion Materials (Books)/Expert SQL Server In-Memory OLTP (2nd Edition)/09.Chapter 09 (In-Memory OLTP Programmability)/02.2.Atomic Blocks.sql: -------------------------------------------------------------------------------- 1 | /****************************************************************************/ 2 | /* Expert SQL Server In-Memory OLTP */ 3 | /* APress. 2nd Edition. ISBN-13:978-1484227718 ISBN-10:1484227719 */ 4 | /* */ 5 | /* Written by Dmitri V. Korotkevitch */ 6 | /* http://aboutsqlserver.com */ 7 | /* dk@aboutsqlserver.com */ 8 | /****************************************************************************/ 9 | /* Chapter 09: In-Memory OLTP Programmability */ 10 | /* 02.Atomic Blocks (Session 2) */ 11 | /****************************************************************************/ 12 | 13 | set nocount on 14 | go 15 | 16 | use InMemoryOLTP2016 17 | go 18 | 19 | 20 | /*** Critical Errors ***/ 21 | -- Run together with Session 1 code 22 | begin tran 23 | exec dbo.AtomicBlockDemo 1, 0, null, null 24 | 25 | -------------------------------------------------------------------------------- /Companion Materials (Books)/Expert SQL Server In-Memory OLTP (2nd Edition)/08.Chapter 08 (Transaction Processing)/06.2.PK Violation.sql: -------------------------------------------------------------------------------- 1 | /****************************************************************************/ 2 | /* Expert SQL Server In-Memory OLTP */ 3 | /* APress. 2nd Edition. ISBN-13:978-1484227718 ISBN-10:1484227719 */ 4 | /* */ 5 | /* Written by Dmitri V. Korotkevitch */ 6 | /* http://aboutsqlserver.com */ 7 | /* dk@aboutsqlserver.com */ 8 | /****************************************************************************/ 9 | /* Chapter 08: Transaction Processing in In-Memory OLTP */ 10 | /* 06.PK Violation (Snapshot Validation) (Session 2) */ 11 | /****************************************************************************/ 12 | 13 | set nocount on 14 | go 15 | 16 | use InMemoryOLTP2016 17 | go 18 | 19 | begin tran 20 | insert into dbo.HKData with (snapshot) 21 | (ID, Col) 22 | values(100,100); 23 | 24 | /*** Commit Tran in Session 1 ***/ 25 | commit 26 | -------------------------------------------------------------------------------- /Companion Materials (Books)/Expert SQL Server In-Memory OLTP (2nd Edition)/08.Chapter 08 (Transaction Processing)/03.2.Serializable.sql: -------------------------------------------------------------------------------- 1 | /****************************************************************************/ 2 | /* Expert SQL Server In-Memory OLTP */ 3 | /* APress. 2nd Edition. ISBN-13:978-1484227718 ISBN-10:1484227719 */ 4 | /* */ 5 | /* Written by Dmitri V. Korotkevitch */ 6 | /* http://aboutsqlserver.com */ 7 | /* dk@aboutsqlserver.com */ 8 | /****************************************************************************/ 9 | /* Chapter 08: Transaction Processing in In-Memory OLTP */ 10 | /* 03.SERIALIZABLE Isolation Level (Session 2) */ 11 | /****************************************************************************/ 12 | 13 | set nocount on 14 | go 15 | 16 | use InMemoryOLTP2016 17 | go 18 | 19 | /*** Test 1 ***/ 20 | update dbo.HKData 21 | set Col = -2 22 | where ID = 2 23 | go 24 | 25 | /*** Test 2 ***/ 26 | insert into dbo.HKData 27 | values(9,9) 28 | go -------------------------------------------------------------------------------- /Companion Materials (Books)/Expert SQL Server Transactions and Locking/12.Chapter 12 (Troubleshooting Concurrency Issues)/06.2.Blocking Chains.sql: -------------------------------------------------------------------------------- 1 | /****************************************************************************/ 2 | /* Expert SQL Server Transactions and Locking */ 3 | /* APress. ISBN-13: 978-1484239568 ISBN-10: 1484239563 */ 4 | /* */ 5 | /* Written by Dmitri V. Korotkevitch */ 6 | /* http://aboutsqlserver.com */ 7 | /* dk@aboutsqlserver.com */ 8 | /****************************************************************************/ 9 | /* Chapter 12. Troubleshooting Concurrency Issues */ 10 | /* Blocking Chain (Session 2) */ 11 | /****************************************************************************/ 12 | 13 | use SQLServerInternals 14 | go 15 | 16 | begin tran 17 | update Delivery.Orders 18 | set Pieces += 1 19 | where OrderId = 1; 20 | 21 | select count(*) 22 | from Delivery.Customers with (readcommitted); 23 | 24 | rollback -------------------------------------------------------------------------------- /Companion Materials (Books)/Applications (Net Code)/Ad-Hoc Demo/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.34014 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace AboutSqlServer.Com.AdHocDemo.Properties { 12 | 13 | 14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "12.0.0.0")] 16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { 17 | 18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 19 | 20 | public static Settings Default { 21 | get { 22 | return defaultInstance; 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Companion Materials (Books)/Expert SQL Server In-Memory OLTP (1st Edition)/07.Chapter 07 (In-Memory OLTP Concurrency Model)/06.2.PK Violation.sql: -------------------------------------------------------------------------------- 1 | /****************************************************************************/ 2 | /* Expert SQL Server In-Memory OLTP */ 3 | /* APress. 1st Edition. ISBN-13:978-1484211373 ISBN-10:1484211375 */ 4 | /* */ 5 | /* Written by Dmitri V. Korotkevitch */ 6 | /* http://aboutsqlserver.com */ 7 | /* dk@aboutsqlserver.com */ 8 | /****************************************************************************/ 9 | /* Chapter 07: In-Memory OLTP Concurrency Model */ 10 | /* 06.PK Violation (Snapshot Validation) (Session 2) */ 11 | /****************************************************************************/ 12 | 13 | set nocount on 14 | go 15 | 16 | use InMemoryOLTP2014 17 | go 18 | 19 | begin tran 20 | insert into dbo.HKData with (snapshot) 21 | (ID, Col) 22 | values(100,100); 23 | 24 | /*** Commit Tran in Session 1 ***/ 25 | commit 26 | -------------------------------------------------------------------------------- /Companion Materials (Books)/Expert SQL Server In-Memory OLTP (2nd Edition)/08.Chapter 08 (Transaction Processing)/02.2.Repeatable Read.sql: -------------------------------------------------------------------------------- 1 | /****************************************************************************/ 2 | /* Expert SQL Server In-Memory OLTP */ 3 | /* APress. 2nd Edition. ISBN-13:978-1484227718 ISBN-10:1484227719 */ 4 | /* */ 5 | /* Written by Dmitri V. Korotkevitch */ 6 | /* http://aboutsqlserver.com */ 7 | /* dk@aboutsqlserver.com */ 8 | /****************************************************************************/ 9 | /* Chapter 08: Transaction Processing in In-Memory OLTP */ 10 | /* 02.REPEATABLE READ Isolation Level (Session 1) */ 11 | /****************************************************************************/ 12 | set nocount on 13 | go 14 | 15 | use InMemoryOLTP2016 16 | go 17 | 18 | 19 | /*** Test 1 ***/ 20 | update dbo.HKData 21 | set Col = -2 22 | where ID = 2 23 | go 24 | 25 | /*** Test 2 ***/ 26 | insert into dbo.HKData 27 | values(10,10) 28 | go -------------------------------------------------------------------------------- /Companion Materials (Books)/Expert SQL Server In-Memory OLTP (2nd Edition)/08.Chapter 08 (Transaction Processing)/04.2.Snapshot.sql: -------------------------------------------------------------------------------- 1 | /****************************************************************************/ 2 | /* Expert SQL Server In-Memory OLTP */ 3 | /* APress. 2nd Edition. ISBN-13:978-1484227718 ISBN-10:1484227719 */ 4 | /* */ 5 | /* Written by Dmitri V. Korotkevitch */ 6 | /* http://aboutsqlserver.com */ 7 | /* dk@aboutsqlserver.com */ 8 | /****************************************************************************/ 9 | /* Chapter 08: Transaction Processing in In-Memory OLTP */ 10 | /* 04.SNAPSHOT Isolation Level (Session 2) */ 11 | /****************************************************************************/ 12 | 13 | set nocount on 14 | go 15 | 16 | use InMemoryOLTP2016 17 | go 18 | 19 | /*** Test 1 ***/ 20 | update dbo.HKData 21 | set Col = -20 22 | where ID = 2 23 | go 24 | 25 | /*** Test 2 ***/ 26 | insert into dbo.HKData 27 | values(8,8) 28 | go 29 | -------------------------------------------------------------------------------- /Companion Materials (Books)/Expert SQL Server In-Memory OLTP (2nd Edition)/08.Chapter 08 (Transaction Processing)/06.1.PK Violation.sql: -------------------------------------------------------------------------------- 1 | /****************************************************************************/ 2 | /* Expert SQL Server In-Memory OLTP */ 3 | /* APress. 2nd Edition. ISBN-13:978-1484227718 ISBN-10:1484227719 */ 4 | /* */ 5 | /* Written by Dmitri V. Korotkevitch */ 6 | /* http://aboutsqlserver.com */ 7 | /* dk@aboutsqlserver.com */ 8 | /****************************************************************************/ 9 | /* Chapter 08: Transaction Processing in In-Memory OLTP */ 10 | /* 06.PK Violation (Snapshot Validation) (Session 1) */ 11 | /****************************************************************************/ 12 | 13 | set nocount on 14 | go 15 | 16 | use InMemoryOLTP2016 17 | go 18 | 19 | -- STEP 1 20 | begin tran 21 | insert into dbo.HKData with (snapshot) 22 | (ID, Col) 23 | values(100,100); 24 | 25 | /*** Run Session 2 code ***/ 26 | commit 27 | -------------------------------------------------------------------------------- /Companion Materials (Books)/Expert SQL Server Transactions and Locking/13.Chapter 13 (In-Memory OLTP Concurrency Model)/06.2.PK Violation.sql: -------------------------------------------------------------------------------- 1 | /****************************************************************************/ 2 | /* Expert SQL Server Transactions and Locking */ 3 | /* APress. ISBN-13: 978-1484239568 ISBN-10: 1484239563 */ 4 | /* */ 5 | /* Written by Dmitri V. Korotkevitch */ 6 | /* http://aboutsqlserver.com */ 7 | /* dk@aboutsqlserver.com */ 8 | /****************************************************************************/ 9 | /* Chapter 13. In-Memory OLTP Concurrency Model */ 10 | /* 06.PK Violation (Snapshot Validation) (Session 2) */ 11 | /****************************************************************************/ 12 | 13 | set nocount on 14 | go 15 | 16 | use SQLServerInternalsHK 17 | go 18 | 19 | begin tran 20 | insert into dbo.HKData with (snapshot) 21 | (ID, Col) 22 | values(100,100); 23 | 24 | /*** Commit Tran in Session 1 ***/ 25 | commit 26 | -------------------------------------------------------------------------------- /Companion Materials (Books)/Applications (Net Code)/SaveRecordSet/SaveRecordSetApp/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.36366 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace SaveRecordSetApp.Properties { 12 | 13 | 14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "12.0.0.0")] 16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { 17 | 18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 19 | 20 | public static Settings Default { 21 | get { 22 | return defaultInstance; 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Companion Materials (Books)/Expert SQL Server In-Memory OLTP (1st Edition)/07.Chapter 07 (In-Memory OLTP Concurrency Model)/03.2.Serializable.sql: -------------------------------------------------------------------------------- 1 | /****************************************************************************/ 2 | /* Expert SQL Server In-Memory OLTP */ 3 | /* APress. 1st Edition. ISBN-13:978-1484211373 ISBN-10:1484211375 */ 4 | /* */ 5 | /* Written by Dmitri V. Korotkevitch */ 6 | /* http://aboutsqlserver.com */ 7 | /* dk@aboutsqlserver.com */ 8 | /****************************************************************************/ 9 | /* Chapter 07: In-Memory OLTP Concurrency Model */ 10 | /* 03.SERIALIZABLE Isolation Level (Session 2) */ 11 | /****************************************************************************/ 12 | 13 | set nocount on 14 | go 15 | 16 | use InMemoryOLTP2014 17 | go 18 | 19 | /*** Test 1 ***/ 20 | update dbo.HKData 21 | set Col = -2 22 | where ID = 2 23 | go 24 | 25 | /*** Test 2 ***/ 26 | insert into dbo.HKData 27 | values(9,9) 28 | go -------------------------------------------------------------------------------- /Companion Materials (Books)/Expert SQL Server Transactions and Locking/13.Chapter 13 (In-Memory OLTP Concurrency Model)/03.2.Serializable.sql: -------------------------------------------------------------------------------- 1 | /****************************************************************************/ 2 | /* Expert SQL Server Transactions and Locking */ 3 | /* APress. ISBN-13: 978-1484239568 ISBN-10: 1484239563 */ 4 | /* */ 5 | /* Written by Dmitri V. Korotkevitch */ 6 | /* http://aboutsqlserver.com */ 7 | /* dk@aboutsqlserver.com */ 8 | /****************************************************************************/ 9 | /* Chapter 13. In-Memory OLTP Concurrency Model */ 10 | /* 03.SERIALIZABLE Isolation Level (Session 2) */ 11 | /****************************************************************************/ 12 | 13 | set nocount on 14 | go 15 | 16 | use SQLServerInternalsHK 17 | go 18 | 19 | /*** Test 1 ***/ 20 | update dbo.HKData 21 | set Col = -2 22 | where ID = 2 23 | go 24 | 25 | /*** Test 2 ***/ 26 | insert into dbo.HKData 27 | values(9,9) 28 | go -------------------------------------------------------------------------------- /Companion Materials (Books)/Pro SQL Server Internals 1st Edition/05.Chapter 05 (Index Fragmentation)/05.Chapter 05 (Index Fragmentation).ssmssqlproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 01.Page Splits.sql 14 | 15 | 16 | 17 | 18 | 19 | 02.Row Size Increase on Update.sql 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Companion Materials (Books)/Pro SQL Server Internals 1st Edition/08.Chapter 08 (Triggers)/08.Chapter 08 (Triggers) (SQL Server 2005).ssmssqlproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 02.Triggers and Fragmentation.sql 14 | 15 | 16 | 17 | 18 | 19 | 03.Context_Info.sql 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Companion Materials (Books)/Pro SQL Server Internals 2nd Edition/06.Chapter 06 (Index Fragmentation)/06.Chapter 06 (Index Fragmentation).ssmssqlproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 01.Page Splits.sql 14 | 15 | 16 | 17 | 18 | 19 | 02.Row Size Increase on Update.sql 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Companion Materials (Books)/Expert SQL Server In-Memory OLTP (1st Edition)/07.Chapter 07 (In-Memory OLTP Concurrency Model)/02.2.Repeatable Read.sql: -------------------------------------------------------------------------------- 1 | /****************************************************************************/ 2 | /* Expert SQL Server In-Memory OLTP */ 3 | /* APress. 1st Edition. ISBN-13:978-1484211373 ISBN-10:1484211375 */ 4 | /* */ 5 | /* Written by Dmitri V. Korotkevitch */ 6 | /* http://aboutsqlserver.com */ 7 | /* dk@aboutsqlserver.com */ 8 | /****************************************************************************/ 9 | /* Chapter 07: In-Memory OLTP Concurrency Model */ 10 | /* 02.REPEATABLE READ Isolation Level (Session 2) */ 11 | /****************************************************************************/ 12 | 13 | set nocount on 14 | go 15 | 16 | use InMemoryOLTP2014 17 | go 18 | 19 | /*** Test 1 ***/ 20 | update dbo.HKData 21 | set Col = -2 22 | where ID = 2 23 | go 24 | 25 | /*** Test 2 ***/ 26 | insert into dbo.HKData 27 | values(10,10) 28 | go -------------------------------------------------------------------------------- /Companion Materials (Books)/Expert SQL Server In-Memory OLTP (1st Edition)/07.Chapter 07 (In-Memory OLTP Concurrency Model)/04.2.Snapshot.sql: -------------------------------------------------------------------------------- 1 | /****************************************************************************/ 2 | /* Expert SQL Server In-Memory OLTP */ 3 | /* APress. 1st Edition. ISBN-13:978-1484211373 ISBN-10:1484211375 */ 4 | /* */ 5 | /* Written by Dmitri V. Korotkevitch */ 6 | /* http://aboutsqlserver.com */ 7 | /* dk@aboutsqlserver.com */ 8 | /****************************************************************************/ 9 | /* Chapter 07: In-Memory OLTP Concurrency Model */ 10 | /* 04.SNAPSHOT Isolation Level (Session 2) */ 11 | /****************************************************************************/ 12 | 13 | set nocount on 14 | go 15 | 16 | use InMemoryOLTP2014 17 | go 18 | 19 | /*** Test 1 ***/ 20 | update dbo.HKData 21 | set Col = -20 22 | where ID = 2 23 | go 24 | 25 | /*** Test 2 ***/ 26 | insert into dbo.HKData 27 | values(8,8) 28 | go 29 | -------------------------------------------------------------------------------- /Companion Materials (Books)/Expert SQL Server In-Memory OLTP (1st Edition)/07.Chapter 07 (In-Memory OLTP Concurrency Model)/06.1.PK Violation.sql: -------------------------------------------------------------------------------- 1 | /****************************************************************************/ 2 | /* Expert SQL Server In-Memory OLTP */ 3 | /* APress. 1st Edition. ISBN-13:978-1484211373 ISBN-10:1484211375 */ 4 | /* */ 5 | /* Written by Dmitri V. Korotkevitch */ 6 | /* http://aboutsqlserver.com */ 7 | /* dk@aboutsqlserver.com */ 8 | /****************************************************************************/ 9 | /* Chapter 07: In-Memory OLTP Concurrency Model */ 10 | /* 06.PK Violation (Snapshot Validation) (Session 1) */ 11 | /****************************************************************************/ 12 | 13 | set nocount on 14 | go 15 | 16 | use InMemoryOLTP2014 17 | go 18 | 19 | -- STEP 1 20 | begin tran 21 | insert into dbo.HKData with (snapshot) 22 | (ID, Col) 23 | values(100,100); 24 | 25 | /*** Run Session 2 code ***/ 26 | commit 27 | -------------------------------------------------------------------------------- /Companion Materials (Books)/Expert SQL Server In-Memory OLTP (1st Edition)/11.Chapter 11 (Untilizing In-Memory OLTP)/03.2.Uniqueness Support.sql: -------------------------------------------------------------------------------- 1 | /****************************************************************************/ 2 | /* Expert SQL Server In-Memory OLTP */ 3 | /* APress. 1st Edition. ISBN-13:978-1484211373 ISBN-10:1484211375 */ 4 | /* */ 5 | /* Written by Dmitri V. Korotkevitch */ 6 | /* http://aboutsqlserver.com */ 7 | /* dk@aboutsqlserver.com */ 8 | /****************************************************************************/ 9 | /* Chapter 11: Utilizing In-Memory OLTP */ 10 | /* 03.Enforcing Uniqueness (Session 2) */ 11 | /****************************************************************************/ 12 | 13 | set nocount on 14 | go 15 | 16 | use InMemoryOLTP2014 17 | go 18 | 19 | 20 | declare 21 | @ProductId int 22 | 23 | exec dbo.InsertProduct 24 | 'Expert SQL Server In-Memory OLTP' 25 | ,'Published by APress' 26 | ,@ProductId output; 27 | -------------------------------------------------------------------------------- /Companion Materials (Books)/Expert SQL Server In-Memory OLTP (2nd Edition)/13.Chapter 13 (Untilizing In-Memory OLTP)/03.2.Uniqueness Support.sql: -------------------------------------------------------------------------------- 1 | /****************************************************************************/ 2 | /* Expert SQL Server In-Memory OLTP */ 3 | /* APress. 1st Edition. ISBN-13:978-1484211373 ISBN-10:1484211375 */ 4 | /* */ 5 | /* Written by Dmitri V. Korotkevitch */ 6 | /* http://aboutsqlserver.com */ 7 | /* dk@aboutsqlserver.com */ 8 | /****************************************************************************/ 9 | /* Chapter 11: Utilizing In-Memory OLTP */ 10 | /* 03.Enforcing Uniqueness (Session 2) */ 11 | /****************************************************************************/ 12 | 13 | set nocount on 14 | go 15 | 16 | use InMemoryOLTP2014 17 | go 18 | 19 | 20 | declare 21 | @ProductId int 22 | 23 | exec dbo.InsertProduct 24 | 'Expert SQL Server In-Memory OLTP' 25 | ,'Published by APress' 26 | ,@ProductId output; 27 | -------------------------------------------------------------------------------- /Companion Materials (Books)/Expert SQL Server Transactions and Locking/13.Chapter 13 (In-Memory OLTP Concurrency Model)/02.2.Repeatable Read.sql: -------------------------------------------------------------------------------- 1 | /****************************************************************************/ 2 | /* Expert SQL Server Transactions and Locking */ 3 | /* APress. ISBN-13: 978-1484239568 ISBN-10: 1484239563 */ 4 | /* */ 5 | /* Written by Dmitri V. Korotkevitch */ 6 | /* http://aboutsqlserver.com */ 7 | /* dk@aboutsqlserver.com */ 8 | /****************************************************************************/ 9 | /* Chapter 13. In-Memory OLTP Concurrency Model */ 10 | /* 02.REPEATABLE READ Isolation Level (Session 1) */ 11 | /****************************************************************************/ 12 | set nocount on 13 | go 14 | 15 | use SQLServerInternalsHK 16 | go 17 | 18 | 19 | /*** Test 1 ***/ 20 | update dbo.HKData 21 | set Col = -2 22 | where ID = 2 23 | go 24 | 25 | /*** Test 2 ***/ 26 | insert into dbo.HKData 27 | values(10,10) 28 | go -------------------------------------------------------------------------------- /Companion Materials (Books)/Expert SQL Server Transactions and Locking/13.Chapter 13 (In-Memory OLTP Concurrency Model)/04.2.Snapshot.sql: -------------------------------------------------------------------------------- 1 | /****************************************************************************/ 2 | /* Expert SQL Server Transactions and Locking */ 3 | /* APress. ISBN-13: 978-1484239568 ISBN-10: 1484239563 */ 4 | /* */ 5 | /* Written by Dmitri V. Korotkevitch */ 6 | /* http://aboutsqlserver.com */ 7 | /* dk@aboutsqlserver.com */ 8 | /****************************************************************************/ 9 | /* Chapter 13. In-Memory OLTP Concurrency Model */ 10 | /* 04.SNAPSHOT Isolation Level (Session 2) */ 11 | /****************************************************************************/ 12 | 13 | set nocount on 14 | go 15 | 16 | use SQLServerInternalsHK 17 | go 18 | 19 | /*** Test 1 ***/ 20 | update dbo.HKData 21 | set Col = -20 22 | where ID = 2 23 | go 24 | 25 | /*** Test 2 ***/ 26 | insert into dbo.HKData 27 | values(8,8) 28 | go 29 | -------------------------------------------------------------------------------- /Companion Materials (Books)/Expert SQL Server Transactions and Locking/13.Chapter 13 (In-Memory OLTP Concurrency Model)/06.1.PK Violation.sql: -------------------------------------------------------------------------------- 1 | /****************************************************************************/ 2 | /* Expert SQL Server Transactions and Locking */ 3 | /* APress. ISBN-13: 978-1484239568 ISBN-10: 1484239563 */ 4 | /* */ 5 | /* Written by Dmitri V. Korotkevitch */ 6 | /* http://aboutsqlserver.com */ 7 | /* dk@aboutsqlserver.com */ 8 | /****************************************************************************/ 9 | /* Chapter 13. In-Memory OLTP Concurrency Model */ 10 | /* 06.PK Violation (Snapshot Validation) (Session 1) */ 11 | /****************************************************************************/ 12 | 13 | set nocount on 14 | go 15 | 16 | use SQLServerInternalsHK 17 | go 18 | 19 | -- STEP 1 20 | begin tran 21 | insert into dbo.HKData with (snapshot) 22 | (ID, Col) 23 | values(100,100); 24 | 25 | /*** Run Session 2 code ***/ 26 | commit 27 | -------------------------------------------------------------------------------- /Companion Materials (Books)/Expert SQL Server Transactions and Locking/07.Chapter 07 (Lock Escalation)/01.2 Lock Escalation and Concurrency.sql: -------------------------------------------------------------------------------- 1 | /****************************************************************************/ 2 | /* Expert SQL Server Transactions and Locking */ 3 | /* APress. ISBN-13: 978-1484239568 ISBN-10: 1484239563 */ 4 | /* */ 5 | /* Written by Dmitri V. Korotkevitch */ 6 | /* http://aboutsqlserver.com */ 7 | /* dk@aboutsqlserver.com */ 8 | /****************************************************************************/ 9 | /* Chapter 07. Lock Escalation */ 10 | /* Disabled Lock Escalation and Concurrency (Session 2) */ 11 | /****************************************************************************/ 12 | 13 | use SQLServerInternals 14 | go 15 | 16 | insert into Delivery.Orders(OrderDate,OrderNum, CustomerId, PickupAddressId 17 | ,DeliveryAddressId, ServiceId, RatePlanId, OrderStatusId, Pieces, Amount) 18 | values('2018-06-01T08:00:00', '123456', 1, 1, 3, 1, 1, 1, 2, 25); -------------------------------------------------------------------------------- /Companion Materials (Books)/Pro SQL Server Internals 1st Edition/19.Chapter 19 (Deadlocks)/02.2.Key Lookup Deadlock.sql: -------------------------------------------------------------------------------- 1 | /****************************************************************************/ 2 | /* Pro SQL Server Internals */ 3 | /* APress. 1st Edition. ISBN-13: 978-1430259626 ISBN-10:1430259620 */ 4 | /* */ 5 | /* Written by Dmitri V. Korotkevitch */ 6 | /* http://aboutsqlserver.com */ 7 | /* dmitri@aboutsqlserver.com */ 8 | /****************************************************************************/ 9 | /* Chapter 19. Deadlocks */ 10 | /* Key Lookup Deadlock (Session 1) */ 11 | /****************************************************************************/ 12 | 13 | set nocount on 14 | go 15 | 16 | use [SqlServerInternals] 17 | go 18 | 19 | -- Session 2 code (Run in parallel with Session 1 code) 20 | declare 21 | @Col int 22 | 23 | while 1 = 1 24 | begin 25 | select @Col = Col1 26 | from dbo.Data 27 | where NCIKey = 10 28 | end 29 | go -------------------------------------------------------------------------------- /Companion Materials (Books)/Pro SQL Server Internals 2nd Edition/19.Chapter 19 (Deadlocks)/02.2.Key Lookup Deadlock.sql: -------------------------------------------------------------------------------- 1 | /****************************************************************************/ 2 | /* Pro SQL Server Internals */ 3 | /* APress. 2nd Edition. ISBN-13: 978-1484219638 ISBN-10:1484219635 */ 4 | /* */ 5 | /* Written by Dmitri V. Korotkevitch */ 6 | /* http://aboutsqlserver.com */ 7 | /* dk@aboutsqlserver.com */ 8 | /****************************************************************************/ 9 | /* Chapter 19. Deadlocks */ 10 | /* Key Lookup Deadlock (Session 2) */ 11 | /****************************************************************************/ 12 | 13 | set nocount on 14 | go 15 | 16 | use [SqlServerInternals] 17 | go 18 | 19 | -- Session 2 code (Run in parallel with Session 1 code) 20 | declare 21 | @Col int 22 | 23 | while 1 = 1 24 | begin 25 | select @Col = Col1 26 | from dbo.Data 27 | where NCIKey = 10; 28 | end 29 | go -------------------------------------------------------------------------------- /Companion Materials (Books)/Applications (Net Code)/CLR/SQL Server 2005/CLRTest.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2013 4 | VisualStudioVersion = 12.0.21005.1 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{00D1A9C2-B5F0-4AF3-8072-F6C62B433612}") = "CLRTest", "CLRTest\CLRTest.sqlproj", "{BED20387-7451-4B4E-9E85-AB3A07666814}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {BED20387-7451-4B4E-9E85-AB3A07666814}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {BED20387-7451-4B4E-9E85-AB3A07666814}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {BED20387-7451-4B4E-9E85-AB3A07666814}.Debug|Any CPU.Deploy.0 = Debug|Any CPU 17 | {BED20387-7451-4B4E-9E85-AB3A07666814}.Release|Any CPU.ActiveCfg = Release|Any CPU 18 | {BED20387-7451-4B4E-9E85-AB3A07666814}.Release|Any CPU.Build.0 = Release|Any CPU 19 | {BED20387-7451-4B4E-9E85-AB3A07666814}.Release|Any CPU.Deploy.0 = Release|Any CPU 20 | EndGlobalSection 21 | GlobalSection(SolutionProperties) = preSolution 22 | HideSolutionNode = FALSE 23 | EndGlobalSection 24 | EndGlobal 25 | -------------------------------------------------------------------------------- /Companion Materials (Books)/Expert SQL Server In-Memory OLTP (1st Edition)/14.Appendix C (Analyzing the States of CFPs)/14.Appendix C (Analyzing the States of CFPs).ssmssqlproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 01.DB Creation.sql 14 | 15 | 16 | 17 | 18 | 19 | 02.Analyzing States.sql 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Companion Materials (Books)/Expert SQL Server In-Memory OLTP (2nd Edition)/16.Appendix C (Analyzing the States of CFPs)/16.Appendix C (Analyzing the States of CFPs).ssmssqlproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 01.DB Creation.sql 14 | 15 | 16 | 17 | 18 | 19 | 02.Analyzing States.sql 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Companion Materials (Books)/Expert SQL Server Transactions and Locking/05.Chapter 05 (Deadlocks)/02.2.Key Lookup Deadlock.sql: -------------------------------------------------------------------------------- 1 | /****************************************************************************/ 2 | /* Expert SQL Server Transactions and Locking */ 3 | /* APress. ISBN-13: 978-1484239568 ISBN-10: 1484239563 */ 4 | /* */ 5 | /* Written by Dmitri V. Korotkevitch */ 6 | /* http://aboutsqlserver.com */ 7 | /* dk@aboutsqlserver.com */ 8 | /****************************************************************************/ 9 | /* Chapter 05. Deadlocks */ 10 | /* Key Lookup Deadlock (Session 2) */ 11 | /****************************************************************************/ 12 | 13 | set nocount on 14 | go 15 | 16 | use SQLServerInternals 17 | go 18 | 19 | -- Session 2 code (Run in parallel with Session 1 code) 20 | declare 21 | @Col int 22 | 23 | while 1 = 1 24 | begin 25 | select @Col = Col1 26 | from dbo.Data 27 | where NCIKey = 10; 28 | end 29 | go -------------------------------------------------------------------------------- /Companion Materials (Books)/Expert SQL Server Transactions and Locking/13.Chapter 13 (In-Memory OLTP Concurrency Model)/07.2.Ref Integrity.sql: -------------------------------------------------------------------------------- 1 | /****************************************************************************/ 2 | /* Expert SQL Server Transactions and Locking */ 3 | /* APress. ISBN-13: 978-1484239568 ISBN-10: 1484239563 */ 4 | /* */ 5 | /* Written by Dmitri V. Korotkevitch */ 6 | /* http://aboutsqlserver.com */ 7 | /* dk@aboutsqlserver.com */ 8 | /****************************************************************************/ 9 | /* Chapter 13. In-Memory OLTP Concurrency Model */ 10 | /* 07.Referential Integrity Enforcement (Session21) */ 11 | /****************************************************************************/ 12 | 13 | set nocount on 14 | go 15 | 16 | 17 | -- Requires SQL Server 2016+ 18 | 19 | use SQLServerInternalsHK 20 | go 21 | 22 | 23 | --Session 2 code 24 | update dbo.Transactions with (snapshot) 25 | set Amount = 30 26 | where TransactionId = 2; 27 | 28 | -------------------------------------------------------------------------------- /Companion Materials (Books)/Applications (Net Code)/CLR/SQL Server 2012-2016/CLRTest.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2013 4 | VisualStudioVersion = 12.0.30110.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{00D1A9C2-B5F0-4AF3-8072-F6C62B433612}") = "CLRTest", "CLRTest\CLRTest.sqlproj", "{BED20387-7451-4B4E-9E85-AB3A07666814}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {BED20387-7451-4B4E-9E85-AB3A07666814}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {BED20387-7451-4B4E-9E85-AB3A07666814}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {BED20387-7451-4B4E-9E85-AB3A07666814}.Debug|Any CPU.Deploy.0 = Debug|Any CPU 17 | {BED20387-7451-4B4E-9E85-AB3A07666814}.Release|Any CPU.ActiveCfg = Release|Any CPU 18 | {BED20387-7451-4B4E-9E85-AB3A07666814}.Release|Any CPU.Build.0 = Release|Any CPU 19 | {BED20387-7451-4B4E-9E85-AB3A07666814}.Release|Any CPU.Deploy.0 = Release|Any CPU 20 | EndGlobalSection 21 | GlobalSection(SolutionProperties) = preSolution 22 | HideSolutionNode = FALSE 23 | EndGlobalSection 24 | EndGlobal 25 | -------------------------------------------------------------------------------- /Companion Materials (Books)/Applications (Net Code)/In-Memory OLTP/SessionStoreDemo/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.34014 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace AboutSqlServer.Com.SessionStoreDemo.Properties { 12 | 13 | 14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "12.0.0.0")] 16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { 17 | 18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 19 | 20 | public static Settings Default { 21 | get { 22 | return defaultInstance; 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Companion Materials (Books)/Pro SQL Server Internals 2nd Edition/04.Chapter 04 (Special Features)/04.Chapter 04 (Special Features) (SQL Server 2005).ssmssqlproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 01.Included Columns.sql 14 | 15 | 16 | 17 | 18 | 19 | 04.Calculated Columns.sql 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Companion Materials (Books)/Applications (Net Code)/CLR/SQL Server 2008-2008R2/CLRTest.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2013 4 | VisualStudioVersion = 12.0.21005.1 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{00D1A9C2-B5F0-4AF3-8072-F6C62B433612}") = "CLRTest", "CLRTest\CLRTest.sqlproj", "{BED20387-7451-4B4E-9E85-AB3A07666814}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {BED20387-7451-4B4E-9E85-AB3A07666814}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {BED20387-7451-4B4E-9E85-AB3A07666814}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {BED20387-7451-4B4E-9E85-AB3A07666814}.Debug|Any CPU.Deploy.0 = Debug|Any CPU 17 | {BED20387-7451-4B4E-9E85-AB3A07666814}.Release|Any CPU.ActiveCfg = Release|Any CPU 18 | {BED20387-7451-4B4E-9E85-AB3A07666814}.Release|Any CPU.Build.0 = Release|Any CPU 19 | {BED20387-7451-4B4E-9E85-AB3A07666814}.Release|Any CPU.Deploy.0 = Release|Any CPU 20 | EndGlobalSection 21 | GlobalSection(SolutionProperties) = preSolution 22 | HideSolutionNode = FALSE 23 | EndGlobalSection 24 | EndGlobal 25 | -------------------------------------------------------------------------------- /Companion Materials (Books)/Expert SQL Server Transactions and Locking/04.Chapter 04 (Blocking In The System)/01.1.Creating Blocking.sql: -------------------------------------------------------------------------------- 1 | /****************************************************************************/ 2 | /* Expert SQL Server Transactions and Locking */ 3 | /* APress. ISBN-13: 978-1484239568 ISBN-10: 1484239563 */ 4 | /* */ 5 | /* Written by Dmitri V. Korotkevitch */ 6 | /* http://aboutsqlserver.com */ 7 | /* dk@aboutsqlserver.com */ 8 | /****************************************************************************/ 9 | /* Chapter 04.Blocking In The System */ 10 | /* Create Blocking Condition (Session 1) */ 11 | /****************************************************************************/ 12 | 13 | use SQLServerInternals 14 | go 15 | 16 | 17 | set transaction isolation level read uncommitted 18 | begin tran 19 | delete from Delivery.Orders 20 | where OrderId = 95; 21 | 22 | -- Run Session 2 code 23 | -- Do not Commit/Rollback transaction 24 | rollback 25 | go -------------------------------------------------------------------------------- /Companion Materials (Books)/Applications (Net Code)/In-Memory OLTP/LogRequestsGenerator/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.34014 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace AboutSqlServer.Com.LogRequestsGenerator.Properties { 12 | 13 | 14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "12.0.0.0")] 16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { 17 | 18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 19 | 20 | public static Settings Default { 21 | get { 22 | return defaultInstance; 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Companion Materials (Books)/Pro SQL Server Internals 1st Edition/16.Chapter 16 (System Design Considerations)/16.Chapter 16 (System Design Considerations).ssmssqlproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 01.Implicit Data Type Conversion.sql 14 | 15 | 16 | 17 | 18 | 19 | 02.EF6 Analysis.sql 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Companion Materials (Books)/Pro SQL Server Internals 2nd Edition/99.Chapter 99 (System Design Considerations)/99.Chapter 99 (System Design Considerations).ssmssqlproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 01.Implicit Data Type Conversion.sql 14 | 15 | 16 | 17 | 18 | 19 | 02.EF6 Analysis.sql 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Companion Materials (Books)/Expert SQL Server In-Memory OLTP (2nd Edition)/06.Chapter 06 (Memory Consumers, Off-Row Storage)/SQLQuery1.sql: -------------------------------------------------------------------------------- 1 | /****************************************************************************/ 2 | /* Expert SQL Server In-Memory OLTP */ 3 | /* APress. 1st Edition. ISBN-13:978-1484211373 ISBN-10:1484211375 */ 4 | /* */ 5 | /* Written by Dmitri V. Korotkevitch */ 6 | /* http://aboutsqlserver.com */ 7 | /* dk@aboutsqlserver.com */ 8 | /****************************************************************************/ 9 | /* Chapter 06: Memory Consumers and Off-Row Storage */ 10 | /* 03. Performance Impact of Off-Row Storage */ 11 | /****************************************************************************/ 12 | 13 | set nocount on 14 | go 15 | 16 | use InMemoryOLTP2016 17 | go 18 | 19 | set statistics time on 20 | 21 | select count(*) 22 | from dbo.HashIndex_LowBucketCount 23 | with (index = PK_HashIndex_LowBucketCount); 24 | 25 | select count(*) 26 | from dbo.HashIndex_LowBucketCount -------------------------------------------------------------------------------- /Companion Materials (Books)/Expert SQL Server In-Memory OLTP (1st Edition)/02.Chapter 02 (In-Memory OLTP Objects)/02.Chapter 02 (In-Memory OLTP Objects).ssmssqlproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 01.Creating Memory-Optimized Objects.sql 14 | 15 | 16 | 17 | 18 | 19 | 02.Creating On-Disk Objects.sql 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Companion Materials (Books)/Expert SQL Server In-Memory OLTP (2nd Edition)/02.Chapter 02 (In-Memory OLTP Objects)/02.Chapter 02 (In-Memory OLTP Objects).ssmssqlproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 01.Creating Memory-Optimized Objects.sql 14 | 15 | 16 | 17 | 18 | 19 | 02.Creating On-Disk Objects.sql 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Companion Materials (Books)/SQL Server Advanced Troubleshooting And Performance Tuning/08.Locking, Blocking and Concurrency/02.2.Deadlocks (Session 2).sql: -------------------------------------------------------------------------------- 1 | /****************************************************************************/ 2 | /* SQL Server Advanced Troubleshooting and Performance Tuning */ 3 | /* O'Reilly, 2022. ISBN-13: 978-1098101923 ISBN-10: 1098101928 */ 4 | /* */ 5 | /* Written by Dmitri V. Korotkevitch */ 6 | /* https://aboutsqlserver.com */ 7 | /* dk@aboutsqlserver.com */ 8 | /****************************************************************************/ 9 | /* Chapter 08: Locking, Blocking and Concurrency */ 10 | /* Deadlocks (Session 2) */ 11 | /****************************************************************************/ 12 | 13 | USE SQLServerInternals 14 | GO 15 | 16 | -- Emulating deadlock 17 | -- Step 1: 18 | BEGIN TRAN 19 | UPDATE dbo.Orders 20 | SET OrderStatus = 1 21 | WHERE OrderId = 250; 22 | 23 | SELECT COUNT(*) AS [Cnt] 24 | FROM dbo.Orders WITH (READCOMMITTEDLOCK) 25 | WHERE CustomerId = 18; 26 | COMMIT -------------------------------------------------------------------------------- /Companion Materials (Books)/Expert SQL Server In-Memory OLTP (2nd Edition)/13.Chapter 13 (Untilizing In-Memory OLTP)/03.2.Referential Integrity.sql: -------------------------------------------------------------------------------- 1 | /****************************************************************************/ 2 | /* Expert SQL Server In-Memory OLTP */ 3 | /* APress. 2nd Edition. ISBN-13:978-1484227718 ISBN-10:1484227719 */ 4 | /* */ 5 | /* Written by Dmitri V. Korotkevitch */ 6 | /* http://aboutsqlserver.com */ 7 | /* dk@aboutsqlserver.com */ 8 | /****************************************************************************/ 9 | /* Chapter 13: Utilizing In-Memory OLTP */ 10 | /* 03.Enforcing Referential Integrity Between */ 11 | /* Disk-Based and Memory-Optimized Tables (Session 2) */ 12 | /****************************************************************************/ 13 | 14 | set nocount on 15 | go 16 | 17 | use InMemoryOLTP2016 18 | go 19 | 20 | -- Session 2 code: Run in oarallel with the transaction that 21 | -- inserts ProductDescription row 22 | delete from dbo.ProductsInMem where ProductId = 1; -------------------------------------------------------------------------------- /Companion Materials (Books)/SQL Server Advanced Troubleshooting And Performance Tuning/09.TempDB Usage and Performance/09.TempDB Usage and Performance.ssmssqlproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 01.Temporary Objects and Cardinalitty Estimations.sql 14 | 15 | 16 | 17 | 18 | 19 | 02.Temporary Object Caching.sql 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Companion Materials (Books)/Pro SQL Server Internals 2nd Edition/01.Chapter 01 (Data Storage Internals)/01.Check Instant File Initialization.sql: -------------------------------------------------------------------------------- 1 | /****************************************************************************/ 2 | /* Pro SQL Server Internals */ 3 | /* APress. 2nd Edition. ISBN-13: 978-1484219638 ISBN-10:1484219635 */ 4 | /* */ 5 | /* Written by Dmitri V. Korotkevitch */ 6 | /* http://aboutsqlserver.com */ 7 | /* dk@aboutsqlserver.com */ 8 | /****************************************************************************/ 9 | /* Chapter 01. Data Storage Internals */ 10 | /* Check if Instant File Initialization is Enabled */ 11 | /****************************************************************************/ 12 | 13 | use master 14 | go 15 | 16 | /*** Checking to see if Instant File Initialization is enabled ***/ 17 | dbcc traceon(3004,3605,-1) 18 | go 19 | 20 | create database Dummy 21 | go 22 | 23 | exec sp_readerrorlog 24 | go 25 | 26 | drop database Dummy 27 | go 28 | 29 | dbcc traceoff(3004,3605,-1) 30 | go 31 | 32 | -------------------------------------------------------------------------------- /Presentations/Intro Into Index Analysis/SQL/03.NCI Usage.sql: -------------------------------------------------------------------------------- 1 | /****************************************************************************/ 2 | /* Intro into Index Analysis */ 3 | /* */ 4 | /* Dmitri V. Korotkevitch */ 5 | /* http://aboutsqlserver.com */ 6 | /* dk@aboutsqlserver.com */ 7 | /****************************************************************************/ 8 | /* NCI Usage */ 9 | /****************************************************************************/ 10 | 11 | use SQLServerInternals 12 | go 13 | 14 | set statistics io on 15 | go 16 | 17 | select count(*) 18 | from dbo.Orders with (index = 1) 19 | go 20 | 21 | select * 22 | from dbo.Orders 23 | where OrderSeq between 1 and 1000; 24 | go 25 | 26 | select * 27 | from dbo.Orders 28 | where OrderSeq between 1 and 10000; 29 | go 30 | 31 | select * 32 | from dbo.Orders 33 | where OrderSeq between 1 and 20000; 34 | go 35 | 36 | select * 37 | from dbo.Orders with (index = IDX_Orders_OrderSeq) 38 | where OrderSeq between 1 and 20000; 39 | go 40 | 41 | select 20000. / count(*) * 100 42 | from dbo.Orders; 43 | go 44 | 45 | 46 | -------------------------------------------------------------------------------- /Companion Materials (Books)/Pro SQL Server Internals 1st Edition/01.Chapter 01 (Data Storage Internals)/01.Check Instant File Initialization.sql: -------------------------------------------------------------------------------- 1 | /****************************************************************************/ 2 | /* Pro SQL Server Internals */ 3 | /* APress. 1st Edition. ISBN-13: 978-1430259626 ISBN-10:1430259620 */ 4 | /* */ 5 | /* Written by Dmitri V. Korotkevitch */ 6 | /* http://aboutsqlserver.com */ 7 | /* dmitri@aboutsqlserver.com */ 8 | /****************************************************************************/ 9 | /* Chapter 01. Data Storage Internals */ 10 | /* Check if Instant File Initialization is enabled */ 11 | /****************************************************************************/ 12 | 13 | use [SqlServerInternals] 14 | go 15 | 16 | /*** Checking to see if Instant File Initialization is enabled ***/ 17 | dbcc traceon(3004,3605,-1) 18 | go 19 | 20 | create database Dummy 21 | go 22 | 23 | exec sp_readerrorlog 24 | go 25 | 26 | drop database Dummy 27 | go 28 | 29 | dbcc traceoff(3004,3605,-1) 30 | go 31 | 32 | -------------------------------------------------------------------------------- /Companion Materials (Books)/Expert SQL Server Transactions and Locking/05.Chapter 05 (Deadlocks)/01.2.Non-optimized Queries Deadlock.sql: -------------------------------------------------------------------------------- 1 | /****************************************************************************/ 2 | /* Expert SQL Server Transactions and Locking */ 3 | /* APress. ISBN-13: 978-1484239568 ISBN-10: 1484239563 */ 4 | /* */ 5 | /* Written by Dmitri V. Korotkevitch */ 6 | /* http://aboutsqlserver.com */ 7 | /* dk@aboutsqlserver.com */ 8 | /****************************************************************************/ 9 | /* Chapter 05. Deadlocks */ 10 | /* Deadlock Due to Non-Optimized Queries (Session 2) */ 11 | /****************************************************************************/ 12 | 13 | use [SQLServerInternals] 14 | go 15 | 16 | set transaction isolation level read committed 17 | begin tran 18 | update Delivery.Orders 19 | set Amount = Amount * 1.1 20 | where OrderId = 1; 21 | 22 | select count(*) as [Cnt] 23 | from Delivery.Orders 24 | where CustomerId = 317; 25 | -- Run Session 1 STEP 2 Code 26 | rollback 27 | go 28 | 29 | -------------------------------------------------------------------------------- /Blocking Monitoring Framework/BMFramework.ssmssln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # SQL Server Management Studio Solution File, Format Version 14.00 4 | VisualStudioVersion = 14.0.23107.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{4F2E2C19-372F-40D8-9FA7-9D2138C6997A}") = "Setup", "Setup\Setup.ssmssqlproj", "{2CF34291-CB0A-4B83-AB18-E9BA302A9CAA}" 7 | EndProject 8 | Project("{4F2E2C19-372F-40D8-9FA7-9D2138C6997A}") = "Testing", "Testing\Testing.ssmssqlproj", "{F8BE65EC-040F-4633-918D-966C8F7703BE}" 9 | EndProject 10 | Project("{4F2E2C19-372F-40D8-9FA7-9D2138C6997A}") = "Analysis", "Analysis\Analysis.ssmssqlproj", "{0A59A6AD-1AA3-454C-A730-C5CBFE6C3C07}" 11 | EndProject 12 | Global 13 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 14 | Default|Default = Default|Default 15 | EndGlobalSection 16 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 17 | {2CF34291-CB0A-4B83-AB18-E9BA302A9CAA}.Default|Default.ActiveCfg = Default 18 | {F8BE65EC-040F-4633-918D-966C8F7703BE}.Default|Default.ActiveCfg = Default 19 | {0304DC00-3608-4174-99C1-03B6E0DB56AF}.Default|Default.ActiveCfg = Default 20 | {0A59A6AD-1AA3-454C-A730-C5CBFE6C3C07}.Default|Default.ActiveCfg = Default 21 | EndGlobalSection 22 | GlobalSection(SolutionProperties) = preSolution 23 | HideSolutionNode = FALSE 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /Companion Materials (Books)/Applications (Net Code)/Ad-Hoc Demo/AdHocDemoStatThread.cs: -------------------------------------------------------------------------------- 1 | /****************************************************************************/ 2 | /* Cautionary Tale of Recompilations, Excessive CPU Load and Plan Caching */ 3 | /* Dmitri V. Korotkevitch */ 4 | /* http://aboutsqlserver.com */ 5 | /* dk@aboutsqlserver.com */ 6 | /****************************************************************************/ 7 | 8 | using System; 9 | using System.Collections.Generic; 10 | using System.Linq; 11 | using System.Text; 12 | using System.Threading.Tasks; 13 | using AboutSqlServer.Com.Classes; 14 | 15 | namespace Actsoft.Com.AdHocDemo 16 | { 17 | public class AdHocDemoStatThread : StatThread 18 | { 19 | public AdHocDemoStatThread(int sleep, List threads, frmMain frmMain) 20 | : base(sleep, threads) 21 | { 22 | _frmMain = frmMain; 23 | } 24 | 25 | protected override void DoIteration() 26 | { 27 | if (!_terminated) 28 | { 29 | _frmMain.Invoke(_frmMain.UpdateExecStats, new object[] { WorkerThreadsCallsPerSec }); 30 | } 31 | } 32 | 33 | private frmMain _frmMain; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /Companion Materials (Books)/Expert SQL Server Transactions and Locking/09.Chapter 09 (Lock Partitioning)/02.2.Lock Partitioning Deadlock.sql: -------------------------------------------------------------------------------- 1 | /****************************************************************************/ 2 | /* Expert SQL Server Transactions and Locking */ 3 | /* APress. ISBN-13: 978-1484239568 ISBN-10: 1484239563 */ 4 | /* */ 5 | /* Written by Dmitri V. Korotkevitch */ 6 | /* http://aboutsqlserver.com */ 7 | /* dk@aboutsqlserver.com */ 8 | /****************************************************************************/ 9 | /* Chapter 09. Lock Partitioning */ 10 | /* Lock Partitioning Deadlock (Session 2) */ 11 | /****************************************************************************/ 12 | 13 | -- You need to have 16 or more schedulers for lock partitioning to be enabled 14 | 15 | -- You can artificially change number of cores with undocumented startup flag -P[N] 16 | -- [N] is number of cores. DO NOT DO THIS IN PRODUCTION! 17 | 18 | 19 | use SQLServerInternals 20 | go 21 | 22 | -- No issues here 23 | alter index PK_Orders on Delivery.Orders rebuild 24 | go 25 | -------------------------------------------------------------------------------- /Companion Materials (Books)/Pro SQL Server Internals 1st Edition/27.Chapter 27 (System Troubleshooting)/04.Buffer Pool Usage.sql: -------------------------------------------------------------------------------- 1 | /****************************************************************************/ 2 | /* Pro SQL Server Internals */ 3 | /* APress. 1st Edition. ISBN-13: 978-1430259626 ISBN-10:1430259620 */ 4 | /* */ 5 | /* Written by Dmitri V. Korotkevitch */ 6 | /* http://aboutsqlserver.com */ 7 | /* dmitri@aboutsqlserver.com */ 8 | /****************************************************************************/ 9 | /* Chapter 27. System Troubleshooting */ 10 | /* Buffer Pool Usage */ 11 | /****************************************************************************/ 12 | 13 | /*** Buffer Pool Usage on Per-Database Basis ***/ 14 | select 15 | database_id as [DB ID] 16 | ,db_name(database_id) as [DB Name] 17 | ,convert(decimal(11,3),count(*) * 8 / 1024.0) as 18 | [Buffer Pool Size (MB)] 19 | from sys.dm_os_buffer_descriptors with (nolock) 20 | group by database_id 21 | order by [Buffer Pool Size (MB)] desc 22 | option (recompile); 23 | go 24 | 25 | -------------------------------------------------------------------------------- /Companion Materials (Books)/Pro SQL Server Internals 2nd Edition/28.Chapter 28 (System Troubleshooting)/04.Buffer Pool Usage.sql: -------------------------------------------------------------------------------- 1 | /****************************************************************************/ 2 | /* Pro SQL Server Internals */ 3 | /* APress. 2nd Edition. ISBN-13: 978-1484219638 ISBN-10:1484219635 */ 4 | /* */ 5 | /* Written by Dmitri V. Korotkevitch */ 6 | /* http://aboutsqlserver.com */ 7 | /* dk@aboutsqlserver.com */ 8 | /****************************************************************************/ 9 | /* Chapter 28. System Troubleshooting */ 10 | /* Buffer Pool Usage */ 11 | /****************************************************************************/ 12 | 13 | /*** Buffer Pool Usage on Per-Database Basis ***/ 14 | select 15 | database_id as [DB ID] 16 | ,db_name(database_id) as [DB Name] 17 | ,convert(decimal(11,3),count(*) * 8 / 1024.0) as 18 | [Buffer Pool Size (MB)] 19 | from sys.dm_os_buffer_descriptors with (nolock) 20 | group by database_id 21 | order by [Buffer Pool Size (MB)] desc 22 | option (recompile); 23 | go 24 | 25 | -------------------------------------------------------------------------------- /Companion Materials (Books)/Expert SQL Server Transactions and Locking/05.Chapter 05 (Deadlocks)/01.1.Non-optimized Queries Deadlock.sql: -------------------------------------------------------------------------------- 1 | /****************************************************************************/ 2 | /* Expert SQL Server Transactions and Locking */ 3 | /* APress. ISBN-13: 978-1484239568 ISBN-10: 1484239563 */ 4 | /* */ 5 | /* Written by Dmitri V. Korotkevitch */ 6 | /* http://aboutsqlserver.com */ 7 | /* dk@aboutsqlserver.com */ 8 | /****************************************************************************/ 9 | /* Chapter 05. Deadlocks */ 10 | /* Deadlock Due to Non-Optimized Queries (Session 1) */ 11 | /****************************************************************************/ 12 | 13 | use [SQLServerInternals] 14 | go 15 | 16 | -- STEP 1 17 | set transaction isolation level read committed 18 | 19 | begin tran 20 | update Delivery.Orders 21 | set Amount = Amount * 1.1 22 | where OrderId = 9999; 23 | 24 | -- Run Session 2 code 25 | 26 | -- STEP 2 27 | select count(*) as [Cnt] 28 | from Delivery.Orders 29 | where CustomerId = 65; 30 | rollback 31 | go 32 | 33 | -------------------------------------------------------------------------------- /Companion Materials (Books)/Expert SQL Server Transactions and Locking/10.Chapter 10 (Application Locks)/04.2.Object Access.sql: -------------------------------------------------------------------------------- 1 | /****************************************************************************/ 2 | /* Expert SQL Server Transactions and Locking */ 3 | /* APress. ISBN-13: 978-1484239568 ISBN-10: 1484239563 */ 4 | /* */ 5 | /* Written by Dmitri V. Korotkevitch */ 6 | /* http://aboutsqlserver.com */ 7 | /* dk@aboutsqlserver.com */ 8 | /****************************************************************************/ 9 | /* Chapter 10. Application Locks */ 10 | /* Preventing Access to the Object (Session 2) */ 11 | /****************************************************************************/ 12 | 13 | set nocount on 14 | go 15 | 16 | use SQLServerInternals 17 | go 18 | 19 | -- Index Rebuild 20 | begin tran 21 | exec sp_getapplock 22 | @Resource = 'TenantDataAccess' 23 | ,@LockMode = 'Exclusive' 24 | ,@LockOwner = 'Transaction' 25 | ,@LockTimeout = -1 ; -- Indefinite wait 26 | 27 | alter index IDX_CollectedData_TenantId_OnDate_Id 28 | on dbo.CollectedData rebuild; 29 | commit -------------------------------------------------------------------------------- /Companion Materials (Books)/Expert SQL Server In-Memory OLTP (1st Edition)/11.Chapter 11 (Untilizing In-Memory OLTP)/08.3.TV Performance DW - Update.sql: -------------------------------------------------------------------------------- 1 | /****************************************************************************/ 2 | /* Expert SQL Server In-Memory OLTP */ 3 | /* APress. 1st Edition. ISBN-13:978-1484211373 ISBN-10:1484211375 */ 4 | /* */ 5 | /* Written by Dmitri V. Korotkevitch */ 6 | /* http://aboutsqlserver.com */ 7 | /* dk@aboutsqlserver.com */ 8 | /****************************************************************************/ 9 | /* Chapter 11: Utilizing In-Memory OLTP */ 10 | /* 08.Memory-Optimized Table Variable Performance (DW) - Update */ 11 | /****************************************************************************/ 12 | 13 | set nocount on 14 | go 15 | 16 | use InMemoryOLTP2014 17 | go 18 | 19 | set statistics time on 20 | 21 | update dw.FactSalesETLDisk set Quantity += 1; 22 | update dw.FactSalesETLDisk set OrderNum += '1234567890'; 23 | 24 | update dw.FactSalesETLMem set Quantity += 1; 25 | update dw.FactSalesETLMem set OrderNum += '1234567890'; 26 | 27 | set statistics time off 28 | 29 | -------------------------------------------------------------------------------- /Companion Materials (Books)/Expert SQL Server Transactions and Locking/14.Chapter 14 (Locking and Columnstore Indexes)/06.Nonclustered Columnstore Indexes.sql: -------------------------------------------------------------------------------- 1 | /****************************************************************************/ 2 | /* Expert SQL Server Transactions and Locking */ 3 | /* APress. ISBN-13: 978-1484239568 ISBN-10: 1484239563 */ 4 | /* */ 5 | /* Written by Dmitri V. Korotkevitch */ 6 | /* http://aboutsqlserver.com */ 7 | /* dk@aboutsqlserver.com */ 8 | /****************************************************************************/ 9 | /* Chapter 14. Locking and Columnstore Indexes */ 10 | /* Nonclustered Columnstore Indexes */ 11 | /****************************************************************************/ 12 | 13 | use SQLServerInternals 14 | go 15 | 16 | drop index IDX_Test_ID on dbo.Test; 17 | drop index CCI_Test on dbo.Test; 18 | go 19 | 20 | create unique clustered index CI_Test_ID 21 | on dbo.Test(ID); 22 | 23 | create nonclustered columnstore index NCCI_Test 24 | on dbo.Test(ID,Col) 25 | with (maxdop=1); 26 | go 27 | 28 | -- Repeat all test and notice that there is no blocking -------------------------------------------------------------------------------- /Companion Materials (Books)/Expert SQL Server In-Memory OLTP (2nd Edition)/08.Chapter 08 (Transaction Processing)/05.2.Write-Write Conflict.sql: -------------------------------------------------------------------------------- 1 | /****************************************************************************/ 2 | /* Expert SQL Server In-Memory OLTP */ 3 | /* APress. 2nd Edition. ISBN-13:978-1484227718 ISBN-10:1484227719 */ 4 | /* */ 5 | /* Written by Dmitri V. Korotkevitch */ 6 | /* http://aboutsqlserver.com */ 7 | /* dk@aboutsqlserver.com */ 8 | /****************************************************************************/ 9 | /* Chapter 08: Transaction Processing in In-Memory OLTP */ 10 | /* 05.Write/Write Conflict (Session 2) */ 11 | /****************************************************************************/ 12 | 13 | set nocount on 14 | go 15 | 16 | use InMemoryOLTP2016 17 | go 18 | 19 | /*** Test 1 ***/ 20 | begin tran 21 | update dbo.HKData with (snapshot) 22 | set Col = -2 23 | where ID = 2 24 | commit 25 | go 26 | 27 | /*** Test 2 ***/ 28 | begin tran 29 | update dbo.HKData with (snapshot) 30 | set Col = -2 31 | where ID = 2 32 | /*** Run Session 1: Step 2 Code ***/ 33 | commit 34 | go -------------------------------------------------------------------------------- /Companion Materials (Books)/Pro SQL Server Internals 2nd Edition/23.Chapter 23 (Schema Locks)/01.2.Schema Locks.sql: -------------------------------------------------------------------------------- 1 | /****************************************************************************/ 2 | /* Pro SQL Server Internals */ 3 | /* APress. 2nd Edition. ISBN-13: 978-1484219638 ISBN-10:1484219635 */ 4 | /* */ 5 | /* Written by Dmitri V. Korotkevitch */ 6 | /* http://aboutsqlserver.com */ 7 | /* dk@aboutsqlserver.com */ 8 | /****************************************************************************/ 9 | /* Chapter 23. Schema Locks */ 10 | /* Schema Lock Demo (Session 2) */ 11 | /****************************************************************************/ 12 | 13 | use [SqlServerInternals] 14 | go 15 | 16 | /****************************************************************************/ 17 | /* That script uses the objects created in "01.DB Creation.sql" script */ 18 | /* from 00.Init project */ 19 | /****************************************************************************/ 20 | 21 | select count(*) 22 | from Delivery.Orders with (nolock); 23 | go -------------------------------------------------------------------------------- /Companion Materials (Books)/Expert SQL Server In-Memory OLTP (1st Edition)/07.Chapter 07 (In-Memory OLTP Concurrency Model)/05.2.Write-Write Conflict.sql: -------------------------------------------------------------------------------- 1 | /****************************************************************************/ 2 | /* Expert SQL Server In-Memory OLTP */ 3 | /* APress. 1st Edition. ISBN-13:978-1484211373 ISBN-10:1484211375 */ 4 | /* */ 5 | /* Written by Dmitri V. Korotkevitch */ 6 | /* http://aboutsqlserver.com */ 7 | /* dk@aboutsqlserver.com */ 8 | /****************************************************************************/ 9 | /* Chapter 07: In-Memory OLTP Concurrency Model */ 10 | /* 05.Write/Write Conflict (Session 2) */ 11 | /****************************************************************************/ 12 | 13 | set nocount on 14 | go 15 | 16 | use InMemoryOLTP2014 17 | go 18 | 19 | /*** Test 1 ***/ 20 | begin tran 21 | update dbo.HKData with (snapshot) 22 | set Col = -2 23 | where ID = 2 24 | commit 25 | go 26 | 27 | /*** Test 2 ***/ 28 | begin tran 29 | update dbo.HKData with (snapshot) 30 | set Col = -2 31 | where ID = 2 32 | /*** Run Session 1: Step 2 Code ***/ 33 | commit 34 | go -------------------------------------------------------------------------------- /Companion Materials (Books)/Expert SQL Server Transactions and Locking/13.Chapter 13 (In-Memory OLTP Concurrency Model)/05.2.Write-Write Conflict.sql: -------------------------------------------------------------------------------- 1 | /****************************************************************************/ 2 | /* Expert SQL Server Transactions and Locking */ 3 | /* APress. ISBN-13: 978-1484239568 ISBN-10: 1484239563 */ 4 | /* */ 5 | /* Written by Dmitri V. Korotkevitch */ 6 | /* http://aboutsqlserver.com */ 7 | /* dk@aboutsqlserver.com */ 8 | /****************************************************************************/ 9 | /* Chapter 13. In-Memory OLTP Concurrency Model */ 10 | /* 05.Write/Write Conflict (Session 2) */ 11 | /****************************************************************************/ 12 | 13 | set nocount on 14 | go 15 | 16 | use SQLServerInternalsHK 17 | go 18 | 19 | /*** Test 1 ***/ 20 | begin tran 21 | update dbo.HKData with (snapshot) 22 | set Col = -2 23 | where ID = 2 24 | commit 25 | go 26 | 27 | /*** Test 2 ***/ 28 | begin tran 29 | update dbo.HKData with (snapshot) 30 | set Col = -2 31 | where ID = 2 32 | /*** Run Session 1: Step 2 Code ***/ 33 | commit 34 | go -------------------------------------------------------------------------------- /Companion Materials (Books)/Expert SQL Server In-Memory OLTP (1st Edition)/04.Chapter 04 (Hash Indexes)/04.Statistics.sql: -------------------------------------------------------------------------------- 1 | /****************************************************************************/ 2 | /* Expert SQL Server In-Memory OLTP */ 3 | /* APress. 1st Edition. ISBN-13:978-1484211373 ISBN-10:1484211375 */ 4 | /* */ 5 | /* Written by Dmitri V. Korotkevitch */ 6 | /* http://aboutsqlserver.com */ 7 | /* dk@aboutsqlserver.com */ 8 | /****************************************************************************/ 9 | /* Chapter 04: Hash Indexes */ 10 | /* 04.Statistics */ 11 | /****************************************************************************/ 12 | 13 | set nocount on 14 | go 15 | 16 | use InMemoryOLTP2014 17 | go 18 | 19 | dbcc show_statistics 20 | ( 21 | 'dbo.HashIndex_HighBucketCount' 22 | ,'PK_HashIndex_HighBucketCount' 23 | ) 24 | go 25 | 26 | update statistics dbo.HashIndex_HighBucketCount 27 | with fullscan, norecompute; 28 | go 29 | 30 | dbcc show_statistics 31 | ( 32 | 'dbo.HashIndex_HighBucketCount' 33 | ,'PK_HashIndex_HighBucketCount' 34 | ) 35 | go 36 | -------------------------------------------------------------------------------- /Companion Materials (Books)/Expert SQL Server Transactions and Locking/07.Chapter 07 (Lock Escalation)/02.Multiple Statements.sql: -------------------------------------------------------------------------------- 1 | /****************************************************************************/ 2 | /* Expert SQL Server Transactions and Locking */ 3 | /* APress. ISBN-13: 978-1484239568 ISBN-10: 1484239563 */ 4 | /* */ 5 | /* Written by Dmitri V. Korotkevitch */ 6 | /* http://aboutsqlserver.com */ 7 | /* dk@aboutsqlserver.com */ 8 | /****************************************************************************/ 9 | /* Chapter 07. Lock Escalation */ 10 | /* Multiple Statements and Lock Escalations */ 11 | /****************************************************************************/ 12 | 13 | use SQLServerInternals 14 | go 15 | 16 | declare 17 | @I int 18 | 19 | select @I = 0; 20 | 21 | begin tran 22 | while @I < 65000 23 | begin 24 | update Delivery.Orders 25 | set OrderStatusId = 1 26 | where OrderId between @I and @I + 4900; 27 | 28 | select @I = @I + 4500; 29 | end 30 | 31 | select count(*) as [Lock Count] 32 | from sys.dm_tran_locks 33 | where request_session_id = @@SPID; 34 | rollback 35 | go -------------------------------------------------------------------------------- /Blocking Monitoring Framework/Setup/06.Enabling Activation.sql: -------------------------------------------------------------------------------- 1 | /****************************************************************************/ 2 | /* Blocking Monitoring Framework */ 3 | /* */ 4 | /* Written by Dmitri V. Korotkevitch */ 5 | /* http://aboutsqlserver.com/bmframework */ 6 | /* dk@aboutsqlserver.com */ 7 | /****************************************************************************/ 8 | /* Initial Setup */ 9 | /* Enable Queue Activation */ 10 | /****************************************************************************/ 11 | 12 | use DBA 13 | go 14 | 15 | alter queue dbo.BlockedProcessNotificationQueue 16 | with 17 | status = ON, 18 | retention = OFF, 19 | activation 20 | ( 21 | Status = ON, 22 | Procedure_Name = dbo.SB_BlockedProcessReport_Activation, 23 | MAX_QUEUE_READERS = 1, 24 | EXECUTE AS OWNER 25 | ); 26 | go 27 | 28 | alter queue dbo.DeadlockNotificationQueue 29 | with 30 | status = ON, 31 | retention = OFF, 32 | activation 33 | ( 34 | Status = ON, 35 | Procedure_Name = dbo.SB_DeadlockEvent_Activation, 36 | max_queue_readers = 1, 37 | execute as owner 38 | ); 39 | go -------------------------------------------------------------------------------- /Companion Materials (Books)/Pro SQL Server Internals 1st Edition/23.Chapter 23 (Schema Locks)/01.2.Schema Locks.sql: -------------------------------------------------------------------------------- 1 | /****************************************************************************/ 2 | /* Pro SQL Server Internals */ 3 | /* APress. 1st Edition. ISBN-13: 978-1430259626 ISBN-10:1430259620 */ 4 | /* */ 5 | /* Written by Dmitri V. Korotkevitch */ 6 | /* http://aboutsqlserver.com */ 7 | /* dmitri@aboutsqlserver.com */ 8 | /****************************************************************************/ 9 | /* Chapter 23. Schema Locks */ 10 | /* Schema Lock Demo (Session 2) */ 11 | /****************************************************************************/ 12 | 13 | set nocount on 14 | go 15 | 16 | use [SqlServerInternals] 17 | go 18 | 19 | /****************************************************************************/ 20 | /* That script uses objects created by "02.Part 5 Objects.sql" script from */ 21 | /* 00.Init project */ 22 | /****************************************************************************/ 23 | 24 | select count(*) 25 | from Delivery.Orders with (nolock) 26 | go -------------------------------------------------------------------------------- /Companion Materials (Books)/Pro SQL Server Internals 2nd Edition/23.Chapter 23 (Schema Locks)/02.2.Lock Compatibility.sql: -------------------------------------------------------------------------------- 1 | /****************************************************************************/ 2 | /* Pro SQL Server Internals */ 3 | /* APress. 2nd Edition. ISBN-13: 978-1484219638 ISBN-10:1484219635 */ 4 | /* */ 5 | /* Written by Dmitri V. Korotkevitch */ 6 | /* http://aboutsqlserver.com */ 7 | /* dk@aboutsqlserver.com */ 8 | /****************************************************************************/ 9 | /* Chapter 23. Schema Locks */ 10 | /* Lock Compatibility (Session 2) */ 11 | /****************************************************************************/ 12 | 13 | use [SqlServerInternals] 14 | go 15 | 16 | /****************************************************************************/ 17 | /* That script uses the objects created in "01.DB Creation.sql" script */ 18 | /* from 00.Init project */ 19 | /****************************************************************************/ 20 | 21 | begin tran 22 | delete 23 | from Delivery.Orders 24 | where OrderId = 1; 25 | rollback -------------------------------------------------------------------------------- /Companion Materials (Books)/Pro SQL Server Internals 1st Edition/00.Init/00.Init (SQL Server 2014).ssmssqlproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 01.DB Creation.sql 14 | 15 | 16 | 17 | 18 | 19 | 02.Part 5 Objects.sql 20 | 21 | 22 | 23 | 24 | 25 | 03.Create Hekaton DB.sql 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /Companion Materials (Books)/Pro SQL Server Internals 2nd Edition/23.Chapter 23 (Schema Locks)/01.3.Schema Locks.sql: -------------------------------------------------------------------------------- 1 | /****************************************************************************/ 2 | /* Pro SQL Server Internals */ 3 | /* APress. 2nd Edition. ISBN-13: 978-1484219638 ISBN-10:1484219635 */ 4 | /* */ 5 | /* Written by Dmitri V. Korotkevitch */ 6 | /* http://aboutsqlserver.com */ 7 | /* dk@aboutsqlserver.com */ 8 | /****************************************************************************/ 9 | /* Chapter 23. Schema Locks */ 10 | /* Schema Lock Demo (Session 3) */ 11 | /****************************************************************************/ 12 | 13 | use [SqlServerInternals] 14 | go 15 | 16 | /****************************************************************************/ 17 | /* That script uses the objects created in "01.DB Creation.sql" script */ 18 | /* from 00.Init project */ 19 | /****************************************************************************/ 20 | 21 | begin tran 22 | delete 23 | from Delivery.Orders 24 | where OrderId = 1; 25 | rollback 26 | go 27 | -------------------------------------------------------------------------------- /Companion Materials (Books)/Pro SQL Server Internals 1st Edition/08.Chapter 08 (Triggers)/08.Chapter 08 (Triggers).ssmssqlproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 01.Merge.sql 14 | 15 | 16 | 17 | 18 | 19 | 02.Triggers and Fragmentation.sql 20 | 21 | 22 | 23 | 24 | 25 | 03.Context_Info.sql 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /Companion Materials (Books)/Pro SQL Server Internals 1st Edition/11.Chapter 11 (XML)/11.Chapter 11 (XML).ssmssqlproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 01.Primary XML Index.sql 14 | 15 | 16 | 17 | 18 | 19 | 02.XML Storage Space.sql 20 | 21 | 22 | 23 | 24 | 25 | 03.Working with XML.sql 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /Companion Materials (Books)/Expert SQL Server Transactions and Locking/08.Chapter 08 (Schema and Low Priority Locks)/02.2.Lock Compatibility.sql: -------------------------------------------------------------------------------- 1 | /****************************************************************************/ 2 | /* Expert SQL Server Transactions and Locking */ 3 | /* APress. ISBN-13: 978-1484239568 ISBN-10: 1484239563 */ 4 | /* */ 5 | /* Written by Dmitri V. Korotkevitch */ 6 | /* http://aboutsqlserver.com */ 7 | /* dk@aboutsqlserver.com */ 8 | /****************************************************************************/ 9 | /* Chapter 08. Schema Locks */ 10 | /* Lock Compatibility (Session 2) */ 11 | /****************************************************************************/ 12 | 13 | use [SqlServerInternals] 14 | go 15 | 16 | /****************************************************************************/ 17 | /* That script uses the objects created in "01.DB Creation.sql" script */ 18 | /* from 00.Init project */ 19 | /****************************************************************************/ 20 | 21 | begin tran 22 | delete 23 | from Delivery.Orders 24 | where OrderId = 1; 25 | rollback -------------------------------------------------------------------------------- /Companion Materials (Books)/Expert SQL Server In-Memory OLTP (1st Edition)/09.Chapter 09 (Garbage Collection)/09.Chapter 09 (Garbage Collection).ssmssqlproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 01.Table Creation.sql 14 | 15 | 16 | 17 | 18 | 19 | 02,DMVs.sql 20 | 21 | 22 | 23 | 24 | 25 | 03.GC In Action.sql 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /Companion Materials (Books)/Pro SQL Server Internals 1st Edition/10.Chapter 10 (Functions)/10.Chapter 10 (Functions).ssmssqlproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 01.Scalar UDF.sql 14 | 15 | 16 | 17 | 18 | 19 | 02.Multi-statement UDF.sql 20 | 21 | 22 | 23 | 24 | 25 | 03.Optimizing with CTE.sql 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /Companion Materials (Books)/Pro SQL Server Internals 1st Edition/23.Chapter 23 (Schema Locks)/02.2.Lock Compatibility.sql: -------------------------------------------------------------------------------- 1 | /****************************************************************************/ 2 | /* Pro SQL Server Internals */ 3 | /* APress. 1st Edition. ISBN-13: 978-1430259626 ISBN-10:1430259620 */ 4 | /* */ 5 | /* Written by Dmitri V. Korotkevitch */ 6 | /* http://aboutsqlserver.com */ 7 | /* dmitri@aboutsqlserver.com */ 8 | /****************************************************************************/ 9 | /* Chapter 23. Schema Locks */ 10 | /* Lock Compatibility (Session 2) */ 11 | /****************************************************************************/ 12 | 13 | set nocount on 14 | go 15 | 16 | use [SqlServerInternals] 17 | go 18 | 19 | /****************************************************************************/ 20 | /* That script uses objects created by "02.Part 5 Objects.sql" script from */ 21 | /* 00.Init project */ 22 | /****************************************************************************/ 23 | 24 | begin tran 25 | delete 26 | from Delivery.Orders 27 | where OrderId = 1 28 | rollback -------------------------------------------------------------------------------- /Companion Materials (Books)/Pro SQL Server Internals 2nd Edition/21.Chapter 21 (Optimistic Isolation Levels)/03.2.Error 3960.sql: -------------------------------------------------------------------------------- 1 | /****************************************************************************/ 2 | /* Pro SQL Server Internals */ 3 | /* APress. 2nd Edition. ISBN-13: 978-1484219638 ISBN-10:1484219635 */ 4 | /* */ 5 | /* Written by Dmitri V. Korotkevitch */ 6 | /* http://aboutsqlserver.com */ 7 | /* dk@aboutsqlserver.com */ 8 | /****************************************************************************/ 9 | /* Chapter 21. Optimistic Isolation Levels */ 10 | /* Snapshot Isolation and Error 3960 (Session 2) */ 11 | /****************************************************************************/ 12 | 13 | use [SqlServerInternals] 14 | go 15 | 16 | /****************************************************************************/ 17 | /* That script uses the objects created in "01.DB Creation.sql" script */ 18 | /* from 00.Init project */ 19 | /****************************************************************************/ 20 | 21 | update Delivery.Orders 22 | set Reference = convert(varchar(48),newid()) 23 | where OrderId = 1; 24 | go 25 | 26 | -------------------------------------------------------------------------------- /Companion Materials (Books)/Expert SQL Server Transactions and Locking/03.Chapter 03 (Lock Types)/03.2.(S) Locks.sql: -------------------------------------------------------------------------------- 1 | /****************************************************************************/ 2 | /* Expert SQL Server Transactions and Locking */ 3 | /* APress. ISBN-13: 978-1484239568 ISBN-10: 1484239563 */ 4 | /* */ 5 | /* Written by Dmitri V. Korotkevitch */ 6 | /* http://aboutsqlserver.com */ 7 | /* dk@aboutsqlserver.com */ 8 | /****************************************************************************/ 9 | /* Chapter 03. Lock Types */ 10 | /* Shared (S) Locks (Session 2) */ 11 | /****************************************************************************/ 12 | 13 | use SQLServerInternals 14 | go 15 | 16 | -- Run Session 1 code without committing transaction 17 | set transaction isolation level repeatable read 18 | begin tran 19 | select 'Session 2:', OrderDate 20 | from Delivery.Orders 21 | where OrderId = 500; 22 | 23 | select request_session_id, 24 | resource_type, resource_description, 25 | request_type, request_mode, request_status 26 | from sys.dm_tran_locks 27 | where request_session_id in (@@spid,); 28 | commit 29 | go 30 | -------------------------------------------------------------------------------- /Companion Materials (Books)/Pro SQL Server Internals 1st Edition/23.Chapter 23 (Schema Locks)/01.3.Schema Locks.sql: -------------------------------------------------------------------------------- 1 | /****************************************************************************/ 2 | /* Pro SQL Server Internals */ 3 | /* APress. 1st Edition. ISBN-13: 978-1430259626 ISBN-10:1430259620 */ 4 | /* */ 5 | /* Written by Dmitri V. Korotkevitch */ 6 | /* http://aboutsqlserver.com */ 7 | /* dmitri@aboutsqlserver.com */ 8 | /****************************************************************************/ 9 | /* Chapter 23. Schema Locks */ 10 | /* Schema Lock Demo (Session 3) */ 11 | /****************************************************************************/ 12 | 13 | set nocount on 14 | go 15 | 16 | use [SqlServerInternals] 17 | go 18 | 19 | /****************************************************************************/ 20 | /* That script uses objects created by "02.Part 5 Objects.sql" script from */ 21 | /* 00.Init project */ 22 | /****************************************************************************/ 23 | 24 | begin tran 25 | delete 26 | from Delivery.Orders 27 | where OrderId = 1 28 | rollback 29 | go 30 | -------------------------------------------------------------------------------- /Companion Materials (Books)/SQL Server Advanced Troubleshooting And Performance Tuning/06.CPU Load/06.CPU Load.ssmssqlproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 01.Parameter-Sensitive Plans.sql 14 | 15 | 16 | 17 | 18 | 19 | 02.Parameter-Value Independence.sql 20 | 21 | 22 | 23 | 24 | 25 | 03.Plan Guides.sql 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /Companion Materials (Books)/Expert SQL Server In-Memory OLTP (1st Edition)/05.Chapter 05 (Nonclustered Indexes)/05.Chapter 05 (Nonclustered Indexes).ssmssqlproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 01.Sargability.sql 14 | 15 | 16 | 17 | 18 | 19 | 02.DMVs.sql 20 | 21 | 22 | 23 | 24 | 25 | 03.Hash vs Nonclustered.sql 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /Companion Materials (Books)/Expert SQL Server In-Memory OLTP (2nd Edition)/08.Chapter 08 (Transaction Processing)/01.Table Creation.sql: -------------------------------------------------------------------------------- 1 | /****************************************************************************/ 2 | /* Expert SQL Server In-Memory OLTP */ 3 | /* APress. 2nd Edition. ISBN-13:978-1484227718 ISBN-10:1484227719 */ 4 | /* */ 5 | /* Written by Dmitri V. Korotkevitch */ 6 | /* http://aboutsqlserver.com */ 7 | /* dk@aboutsqlserver.com */ 8 | /****************************************************************************/ 9 | /* Chapter 08: Transaction Processing in In-Memory OLTP */ 10 | /* 01.Table Creation */ 11 | /****************************************************************************/ 12 | 13 | set nocount on 14 | go 15 | 16 | use InMemoryOLTP2016 17 | go 18 | 19 | drop table if exists dbo.HKData; 20 | go 21 | 22 | create table dbo.HKData 23 | ( 24 | ID int not null, 25 | Col int not null, 26 | 27 | constraint PK_HKData 28 | primary key nonclustered hash(ID) 29 | with (bucket_count=64), 30 | ) 31 | with (memory_optimized=on, durability=schema_only) 32 | go 33 | 34 | insert into dbo.HKData(ID, Col) 35 | values(1,1),(2,2),(3,3),(4,4),(5,5); 36 | go 37 | 38 | --------------------------------------------------------------------------------